安卓开发选取城市列表

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Scorpio_gao/article/details/51242506




public class Activity01 extends Activity implements OnScrollListener {

private DatabaseHelper helper;
private ListView Listview;
private ArrayList<City> allCity_lists; // 所有城市列表
private ArrayList<City> hotcity_lists; // 热门城市列表
private ArrayList<City> city_result;
private ArrayList<City> city_lists;// 城市列表
private ListView resultList;
private EditText sh;
private TextView tv_noresult;
private MyLetterListView letterListView; // A-Z listview


private ResultListAdapter resultListAdapter;
private HashMap<String, Integer> alphaIndexer;// 存放存在的汉语拼音首字母和与之对应的列表位置
private String[] sections;// 存放存在的汉语拼音首字母
private Handler handler;
private OverlayThread overlayThread; // 显示首字母对话框
private TextView overlay; // 对话框首字母textview
private boolean isNeedFresh;


private BaseAdapter adapter;


@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
allCity_lists = new ArrayList<City>();
hotcity_lists = new ArrayList<City>();
city_result = new ArrayList<City>();
Listview = (ListView) findViewById(R.id.list_view);
sh = (EditText) findViewById(R.id.sh);
tv_noresult = (TextView) findViewById(R.id.tv_noresult);
letterListView = (MyLetterListView) findViewById(R.id.MyLetterListView01);
resultList = (ListView) findViewById(R.id.search_result);
helper = new DatabaseHelper(this);
sh.addTextChangedListener(new TextWatcher() {


@Override
public void onTextChanged(CharSequence s, int start, int before,
int count) {
if (s.toString() == null || "".equals(s.toString())) {
letterListView.setVisibility(View.VISIBLE);
Listview.setVisibility(View.VISIBLE);
resultList.setVisibility(View.GONE);
tv_noresult.setVisibility(View.GONE);
} else {
city_result.clear();
letterListView.setVisibility(View.GONE);
Listview.setVisibility(View.GONE);
getResultCityList(s.toString());
if (city_result.size() <= 0) {
tv_noresult.setVisibility(View.VISIBLE);
resultList.setVisibility(View.GONE);
} else {
tv_noresult.setVisibility(View.GONE);
resultList.setVisibility(View.VISIBLE);
resultListAdapter.notifyDataSetChanged();
}
}
}


@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}


@Override
public void afterTextChanged(Editable s) {


}
});


resultListAdapter = new ResultListAdapter(this, city_result);
letterListView
.setOnTouchingLetterChangedListener(new LetterListViewListener());
alphaIndexer = new HashMap<String, Integer>();
handler = new Handler();
overlayThread = new OverlayThread();
isNeedFresh = true;
Listview.setOnItemClickListener(new OnItemClickListener() {


@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
if (position >= 2) {
Toast.makeText(getApplicationContext(),
allCity_lists.get(position).getName(),
Toast.LENGTH_SHORT).show();
}
}
});
Listview.setAdapter(adapter);
Listview.setOnScrollListener(this);
resultListAdapter = new ResultListAdapter(this, city_result);
resultList.setAdapter(resultListAdapter);
resultList.setOnItemClickListener(new OnItemClickListener() {


@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
Toast.makeText(getApplicationContext(),
city_result.get(position).getName(), Toast.LENGTH_SHORT)
.show();
}
});
initOverlay();
cityInit();
hotCityInit();
setAdapter(allCity_lists, hotcity_lists);


}


private void cityInit() {
City city = new City("热门", "0"); // 热门城市
allCity_lists.add(city);
city = new City("全部", "1"); // 全部城市
allCity_lists.add(city);


city_lists = getCityList();
allCity_lists.addAll(city_lists);
}


/**
* 热门城市
*/
public void hotCityInit() {
City city = new City("上海", "0");
hotcity_lists.add(city);
city = new City("北京", "0");
hotcity_lists.add(city);
city = new City("广州", "0");
hotcity_lists.add(city);
city = new City("深圳", "0");
hotcity_lists.add(city);
city = new City("武汉", "0");
hotcity_lists.add(city);
city = new City("天津", "0");
hotcity_lists.add(city);
city = new City("西安", "0");
hotcity_lists.add(city);
city = new City("合肥", "0");
hotcity_lists.add(city);
city = new City("南京", "0");
hotcity_lists.add(city);
city = new City("杭州", "0");
hotcity_lists.add(city);
city = new City("成都", "0");
hotcity_lists.add(city);
city = new City("重庆", "0");
hotcity_lists.add(city);


}


private void setAdapter(List<City> list, List<City> hotList) {
adapter = new ListAdapter(this, list, hotList);
Listview.setAdapter(adapter);
}


public class ListAdapter extends BaseAdapter {
private Context context;
private LayoutInflater inflater;
private List<City> list;
private List<City> hotList;
final int VIEW_TYPE = 3;


public ListAdapter(Context context, List<City> list, List<City> hotList) {
this.inflater = LayoutInflater.from(context);
this.list = list;
this.context = context;
this.hotList = hotList;
alphaIndexer = new HashMap<String, Integer>();
sections = new String[list.size()];
for (int i = 0; i < list.size(); i++) {
// 当前汉语拼音首字母
String currentStr = getAlpha(list.get(i).getPinyi());
// 上一个汉语拼音首字母,如果不存在为" "
String previewStr = (i - 1) >= 0 ? getAlpha(list.get(i - 1)
.getPinyi()) : " ";
if (!previewStr.equals(currentStr)) {
String name = getAlpha(list.get(i).getPinyi());
alphaIndexer.put(name, i);
sections[i] = name;
}
}
}


@Override
public int getViewTypeCount() {
return VIEW_TYPE;
}


@Override
public int getItemViewType(int position) {
return position < 2 ? position : 2;
}


@Override
public int getCount() {
return list.size();
}


@Override
public Object getItem(int position) {
return list.get(position);
}


@Override
public long getItemId(int position) {
return position;
}


ViewHolder holder;


@Override
public View getView(int position, View convertView, ViewGroup parent) {
final TextView city;
int viewType = getItemViewType(position);
if (viewType == 0) {
convertView = inflater.inflate(R.layout.recent_city, null);
GridView hotCity = (GridView) convertView
.findViewById(R.id.recent_city);
hotCity.setOnItemClickListener(new OnItemClickListener() {


@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {


Toast.makeText(getApplicationContext(),
hotcity_lists.get(position).getName(),
Toast.LENGTH_SHORT).show();


}
});
hotCity.setAdapter(new HotCityAdapter(context, this.hotList));
TextView hotHint = (TextView) convertView
.findViewById(R.id.recentHint);
hotHint.setText("热门城市");
} else if (viewType == 1) {
convertView = inflater.inflate(R.layout.total_item, null);
} else {
if (convertView == null) {
convertView = inflater.inflate(R.layout.list_item, null);
holder = new ViewHolder();
holder.alpha = (TextView) convertView
.findViewById(R.id.alpha);
holder.name = (TextView) convertView
.findViewById(R.id.name);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
if (position >= 1) {
holder.name.setText(list.get(position).getName());
String currentStr = getAlpha(list.get(position).getPinyi());
String previewStr = (position - 1) >= 0 ? getAlpha(list
.get(position - 1).getPinyi()) : " ";
if (!previewStr.equals(currentStr)) {
holder.alpha.setVisibility(View.VISIBLE);
holder.alpha.setText(currentStr);
} else {
holder.alpha.setVisibility(View.GONE);
}
}
}
return convertView;
}


private class ViewHolder {
TextView alpha; // 首字母标题
TextView name; // 城市名字
}
}


class HotCityAdapter extends BaseAdapter {
private Context context;
private LayoutInflater inflater;
private List<City> hotCitys;


public HotCityAdapter(Context context, List<City> hotCitys) {
this.context = context;
inflater = LayoutInflater.from(this.context);
this.hotCitys = hotCitys;
}


@Override
public int getCount() {
return hotCitys.size();
}


@Override
public Object getItem(int position) {
return position;
}


@Override
public long getItemId(int position) {
return position;
}


@Override
public View getView(int position, View convertView, ViewGroup parent) {
convertView = inflater.inflate(R.layout.item_city, null);
TextView city = (TextView) convertView.findViewById(R.id.city);
city.setText(hotCitys.get(position).getName());
return convertView;
}
}


// 获得汉语拼音首字母
private String getAlpha(String str) {
if (str == null) {
return "#";
}
if (str.trim().length() == 0) {
return "#";
}
char c = str.trim().substring(0, 1).charAt(0);
// 正则表达式,判断首字母是否是英文字母
Pattern pattern = Pattern.compile("^[A-Za-z]+$");
if (pattern.matcher(c + "").matches()) {
return (c + "").toUpperCase();
} else if (str.equals("0")) {
return "热门";
} else if (str.equals("1")) {
return "全部";
} else {
return "#";
}
}


private ArrayList<City> getCityList() {
DBHelper dbHelper = new DBHelper(this);
ArrayList<City> list = new ArrayList<City>();
try {
dbHelper.createDataBase();
SQLiteDatabase db = dbHelper.getWritableDatabase();
Cursor cursor = db.rawQuery("select * from city", null);
City city;
while (cursor.moveToNext()) {
city = new City(cursor.getString(1), cursor.getString(2));
list.add(city);
}
cursor.close();
db.close();
} catch (IOException e) {
e.printStackTrace();
}
Collections.sort(list, comparator);
return list;
}


private void getResultCityList(String keyword) {
DBHelper dbHelper = new DBHelper(this);
try {
dbHelper.createDataBase();
SQLiteDatabase db = dbHelper.getWritableDatabase();
Cursor cursor = db.rawQuery(
"select * from city where name like \"%" + keyword
+ "%\" or pinyin like \"%" + keyword + "%\"", null);
City city;
Log.e("info", "length = " + cursor.getCount());
while (cursor.moveToNext()) {
city = new City(cursor.getString(1), cursor.getString(2));
city_result.add(city);
}
cursor.close();
db.close();
} catch (IOException e) {
e.printStackTrace();
}
Collections.sort(city_result, comparator);
}


/**
* a-z排序
*/
@SuppressWarnings("rawtypes")
Comparator comparator = new Comparator<City>() {
@Override
public int compare(City lhs, City rhs) {
String a = lhs.getPinyi().substring(0, 1);
String b = rhs.getPinyi().substring(0, 1);
int flag = a.compareTo(b);
if (flag == 0) {
return a.compareTo(b);
} else {
return flag;
}
}
};


private class ResultListAdapter extends BaseAdapter {
private LayoutInflater inflater;
private ArrayList<City> results = new ArrayList<City>();


public ResultListAdapter(Context context, ArrayList<City> results) {
inflater = LayoutInflater.from(context);
this.results = results;
}


@Override
public int getCount() {
return results.size();
}


@Override
public Object getItem(int position) {
return position;
}


@Override
public long getItemId(int position) {
return position;
}


@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder = null;
if (convertView == null) {
convertView = inflater.inflate(R.layout.list_item, null);
viewHolder = new ViewHolder();
viewHolder.name = (TextView) convertView
.findViewById(R.id.name);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
viewHolder.name.setText(results.get(position).getName());
return convertView;
}


class ViewHolder {
TextView name;
}
}


private boolean isScroll = false;


private class LetterListViewListener implements
OnTouchingLetterChangedListener {


@Override
public void onTouchingLetterChanged(final String s) {
isScroll = false;
if (alphaIndexer.get(s) != null) {
int position = alphaIndexer.get(s);
Listview.setSelection(position);
overlay.setText(s);
overlay.setVisibility(View.VISIBLE);
handler.removeCallbacks(overlayThread);
// 延迟一秒后执行,让overlay为不可见
handler.postDelayed(overlayThread, 1000);
}
}
}


// 设置overlay不可见
private class OverlayThread implements Runnable {
@Override
public void run() {
overlay.setVisibility(View.GONE);
}
}


private boolean mReady;


// 初始化汉语拼音首字母弹出提示框
private void initOverlay() {
mReady = true;
LayoutInflater inflater = LayoutInflater.from(this);
overlay = (TextView) inflater.inflate(R.layout.overlay, null);
overlay.setVisibility(View.INVISIBLE);
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_APPLICATION,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
| WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,
PixelFormat.TRANSLUCENT);
WindowManager windowManager = (WindowManager) this
.getSystemService(Context.WINDOW_SERVICE);
windowManager.addView(overlay, lp);
}


@Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
if (!isScroll) {
return;
}
if (mReady) {
String text;
String name = allCity_lists.get(firstVisibleItem).getName();
String pinyin = allCity_lists.get(firstVisibleItem).getPinyi();
if (firstVisibleItem < 2) {
text = name;
overlay.setVisibility(View.INVISIBLE);
} else {
text = PingYinUtil.converterToFirstSpell(pinyin)
.substring(0, 1).toUpperCase();
overlay.setVisibility(View.VISIBLE);
}
overlay.setText(text);
handler.removeCallbacks(overlayThread);
// 延迟一秒后执行,让overlay为不可见
handler.postDelayed(overlayThread, 1000);
}
}


@Override
public void onScrollStateChanged(AbsListView arg0, int scrollState) {
// TODO Auto-generated method stub
if (scrollState == SCROLL_STATE_TOUCH_SCROLL
|| scrollState == SCROLL_STATE_FLING) {
isScroll = true;
}
}


}


public class City {
public String name;
public String pinyi;


public City(String name, String pinyi) {
super();
this.name = name;
this.pinyi = pinyi;
}


public City() {
super();
}


public String getName() {
return name;
}


public void setName(String name) {
this.name = name;
}


public String getPinyi() {
return pinyi;
}


public void setPinyi(String pinyi) {
this.pinyi = pinyi;
}


}

public class DatabaseHelper extends SQLiteOpenHelper {
// 类没有实例化,是不能用作父类构造器的参数,必须声明为静态
private static final String name = "city"; // 数据库名称
private static final int version = 1; // 数据库版本


public DatabaseHelper(Context context) {
super(context, name, null, version);
}


@Override
public void onCreate(SQLiteDatabase db) {
Log.e("info", "create table");
db.execSQL("CREATE TABLE IF NOT EXISTS recentcity (id integer primary key autoincrement, name varchar(40), date INTEGER)");
}


@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
}


public class DBHelper extends SQLiteOpenHelper {
// 用户数据库文件的版本
private static final int DB_VERSION = 3;
// 数据库文件目标存放路径为系统默认位置,com.droid 是你的包名
private static String DB_PATH = "/data/data/com.droid/databases/";
/*
* //如果你想把数据库文件存放在SD卡的话 private static String DB_PATH =
* android.os.Environment.getExternalStorageDirectory().getAbsolutePath() +
* "/arthurcn/drivertest/packfiles/";
*/
private static String DB_NAME = "meituan_cities.db";
private static String ASSETS_NAME = "cities.db";


private SQLiteDatabase myDataBase = null;
private final Context myContext;


/**
* 如果数据库文件较大,使用FileSplit分割为小于1M的小文件 此例中分割为 hello.db.101 hello.db.102
* hello.db.103
*/
// 第一个文件名后缀
private static final int ASSETS_SUFFIX_BEGIN = 101;
// 最后一个文件名后缀
private static final int ASSETS_SUFFIX_END = 103;


/**
* 在SQLiteOpenHelper的子类当中,必须有该构造函数

* @param context
*            上下文对象
* @param name
*            数据库名称
* @param factory
*            一般都是null
* @param version
*            当前数据库的版本,值必须是整数并且是递增的状态
*/
public DBHelper(Context context, String name, CursorFactory factory,
int version) {
// 必须通过super调用父类当中的构造函数
super(context, name, null, version);
this.myContext = context;
}


public DBHelper(Context context, String name, int version) {
this(context, name, null, version);
}


public DBHelper(Context context, String name) {
this(context, name, DB_VERSION);
}


public DBHelper(Context context) {
this(context, DB_PATH + DB_NAME);
}


public void createDataBase() throws IOException {
boolean dbExist = checkDataBase();
if (dbExist) {
// 数据库已存在,do nothing.
} else {
// 创建数据库
try {
File dir = new File(DB_PATH);
if (!dir.exists()) {
dir.mkdirs();
}
File dbf = new File(DB_PATH + DB_NAME);
if (dbf.exists()) {
dbf.delete();
}
SQLiteDatabase.openOrCreateDatabase(dbf, null);
// 复制asseets中的db文件到DB_PATH下
copyDataBase();
} catch (IOException e) {
throw new Error("数据库创建失败");
}
}
}


// 检查数据库是否有效
private boolean checkDataBase() {
SQLiteDatabase checkDB = null;
String myPath = DB_PATH + DB_NAME;
try {
checkDB = SQLiteDatabase.openDatabase(myPath, null,
SQLiteDatabase.OPEN_READONLY);
} catch (SQLiteException e) {
// database does't exist yet.
}
if (checkDB != null) {
checkDB.close();
}
return checkDB != null ? true : false;
}


/**
* Copies your database from your local assets-folder to the just created
* empty database in the system folder, from where it can be accessed and
* handled. This is done by transfering bytestream.
* */
private void copyDataBase() throws IOException {
// Open your local db as the input stream
InputStream myInput = myContext.getAssets().open(ASSETS_NAME);
// Path to the just created empty db
String outFileName = DB_PATH + DB_NAME;
// Open the empty db as the output stream
OutputStream myOutput = new FileOutputStream(outFileName);
// transfer bytes from the inputfile to the outputfile
byte[] buffer = new byte[1024];
int length;
while ((length = myInput.read(buffer)) > 0) {
myOutput.write(buffer, 0, length);
}
// Close the streams
myOutput.flush();
myOutput.close();
myInput.close();
}


// 复制assets下的大数据库文件时用这个
@SuppressWarnings("unused")
private void copyBigDataBase() throws IOException {
InputStream myInput;
String outFileName = DB_PATH + DB_NAME;
OutputStream myOutput = new FileOutputStream(outFileName);
for (int i = ASSETS_SUFFIX_BEGIN; i < ASSETS_SUFFIX_END + 1; i++) {
myInput = myContext.getAssets().open(ASSETS_NAME + "." + i);
byte[] buffer = new byte[1024];
int length;
while ((length = myInput.read(buffer)) > 0) {
myOutput.write(buffer, 0, length);
}
myOutput.flush();
myInput.close();
}
myOutput.close();
}


@Override
public synchronized void close() {
if (myDataBase != null) {
myDataBase.close();
}
super.close();
}


/**
* 该函数是在第一次创建的时候执行, 实际上是第一次得到SQLiteDatabase对象的时候才会调用这个方法
*/
@Override
public void onCreate(SQLiteDatabase db) {

}


/**
* 数据库表结构有变化时采用
*/
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}


}


public class MyGridView extends GridView {
public MyGridView(android.content.Context context,
android.util.AttributeSet attrs) {
super(context, attrs);
}


/**
* 设置不滚动
*/
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, expandSpec);
}
}

public class MyLetterListView extends View {


OnTouchingLetterChangedListener onTouchingLetterChangedListener;
String[] b = {"热门", "全部", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K",
"L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X",
"Y", "Z" };
int choose = -1;
Paint paint = new Paint();
boolean showBkg = false;


public MyLetterListView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}


public MyLetterListView(Context context, AttributeSet attrs) {
super(context, attrs);
}


public MyLetterListView(Context context) {
super(context);
}


@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (showBkg) {
canvas.drawColor(Color.parseColor("#40000000"));
}
int height = getHeight();
int width = getWidth();
int singleHeight = height / b.length;
for (int i = 0; i < b.length; i++) {
paint.setColor(Color.parseColor("#8c8c8c"));
paint.setTextSize(20);
// paint.setTypeface(Typeface.DEFAULT_BOLD);
paint.setAntiAlias(true);
/*if (i == choose) {
paint.setColor(Color.parseColor("#3399ff"));
paint.setFakeBoldText(true);
}*/
float xPos = width / 2 - paint.measureText(b[i]) / 2;
float yPos = singleHeight * i + singleHeight;
canvas.drawText(b[i], xPos, yPos, paint);
paint.reset();
}
}


@Override
public boolean dispatchTouchEvent(MotionEvent event) {
final int action = event.getAction();
final float y = event.getY();
final int oldChoose = choose;
final OnTouchingLetterChangedListener listener = onTouchingLetterChangedListener;
final int c = (int) (y / getHeight() * b.length);
switch (action) {
case MotionEvent.ACTION_DOWN:
showBkg = true;
if (oldChoose != c && listener != null) {
if (c >= 0 && c < b.length) {
listener.onTouchingLetterChanged(b[c]);
choose = c;
invalidate();
}
}
break;
case MotionEvent.ACTION_MOVE:
if (oldChoose != c && listener != null) {
if (c >= 0 && c < b.length) {
listener.onTouchingLetterChanged(b[c]);
choose = c;
invalidate();
}
}
break;
case MotionEvent.ACTION_UP:
showBkg = false;
choose = -1;
invalidate();
break;
}
return true;
}


@Override
public boolean onTouchEvent(MotionEvent event) {
return super.onTouchEvent(event);
}


public void setOnTouchingLetterChangedListener(
OnTouchingLetterChangedListener onTouchingLetterChangedListener) {
this.onTouchingLetterChangedListener = onTouchingLetterChangedListener;
}


public interface OnTouchingLetterChangedListener {
public void onTouchingLetterChanged(String s);
}
}


public class PingYinUtil {


/**
* 将字符串中的中文转化为拼音,其他字符不变
*/
public static String getPingYin(String inputString) {
HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat();
format.setCaseType(HanyuPinyinCaseType.LOWERCASE);
format.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
format.setVCharType(HanyuPinyinVCharType.WITH_V);


Pattern p = Pattern.compile("^[\u4E00-\u9FA5A-Za-z_]+$");
Matcher matcher = p.matcher(inputString.substring(0, 1));
if (matcher.find()) {
char[] input = inputString.trim().toCharArray();
String output = "";
try {
for (int i = 0; i < input.length; i++) {
if (java.lang.Character.toString(input[i]).matches(
"[\\u4E00-\\u9FA5]+")) {
String[] temp = PinyinHelper.toHanyuPinyinStringArray(
input[i], format);
output += temp[0];
} else
output += java.lang.Character.toString(input[i]);
}
} catch (BadHanyuPinyinOutputFormatCombination e) {
e.printStackTrace();
}
return output;
} else {
return "";
}
}


public static String converterToFirstSpell(String chines) {
String pinyinName = "";
char[] nameChar = chines.toCharArray();
HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat();
defaultFormat.setCaseType(HanyuPinyinCaseType.UPPERCASE);
defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
for (int i = 0; i < nameChar.length; i++) {
if (nameChar[i] > 128) {
try {
pinyinName += PinyinHelper.toHanyuPinyinStringArray(
nameChar[i], defaultFormat)[0].charAt(0);
} catch (BadHanyuPinyinOutputFormatCombination e) {
e.printStackTrace();
}
} else {
pinyinName += nameChar[i];
}
}
return pinyinName;
}
}






展开阅读全文

没有更多推荐了,返回首页