AlertDialog.Builder
System.out.println("fdkddddddddddddddd");
final EditText theDestination=new EditText(this);
//placeLocation=new Location(provider);
new AlertDialog.Builder(this)
.setTitle("请输入")
.setIcon(android.R.drawable.ic_dialog_info)
.setView(theDestination)
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
String destination=theDestination.getText().toString();
searchName(destination);
}
})
.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
})
.show();
public void chooseRoute() {
new AlertDialog.Builder(Main.this)
.setTitle(R.string.alert_title_route)
.setAdapter(new ArrayAdapter<String>(Main.this,R.layout.item,R.id.textViewId,getRoute()),
new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
routetag=routeList.get(which);
//EDITTEXT_SEARCH_ROUTE=routeList.get(which);
String dirRouteKey=routeList.get(which);
new AlertDialog.Builder(Main.this)
.setTitle("选择方向")
.setAdapter(new ArrayAdapter<String>(Main.this,R.layout.item,R.id.textViewId,getDirection(dirRouteKey)),new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
directiondir=directionList.get(which);
editText_searchRoute.setText(directiondir);
getTag(directionList.get(which));
if(2==style){
getPoint(stoptagList);
//将记录保存到搜索框中
}
if(1==style){
//显示车辆信息。
busOnRoute_dir();
}
suggestions.saveRecentQuery(routetag+"#"+directiondir, null);
}
}).show();
}
}).show();
}
这个xml文件就是用来定义文字的排版的,里面可以设置文件的大小,样式
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/textViewId"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="28dip"
/>
</LinearLayout>
spinner
public static final String[] toggleModeText;
public static final int[] toggleModeIcons;
public static final int[] toggleMode = {1,2, 3, 4 };
static {
toggleModeText = new String[4];
toggleModeText[0]="clear the layout";
toggleModeText[1] = "Buses on one route";
toggleModeText[2] = "Stops and predictions on one route";
toggleModeText[3] = "Favorite stops";
toggleModeIcons = new int[] {R.drawable.bus_all,R.drawable.bus_one, R.drawable.busstop_one, R.drawable.busstop_star };
}
spr_toggleMode = (Spinner) findViewById(R.id.predictionsOrLocations);
spr_toggleMode.setAdapter(getToggleModeSpinner());
/**
* 获取Adapter for Toggle Mode Spinner
*
* @return
*/
private SpinnerAdapter getToggleModeSpinner() {
ArrayList<ToggleModeLineInfo> modeList = new ArrayList<ToggleModeLineInfo>();
int length = toggleMode.length;
for (int i = 0; i < length; i++) {
int j = toggleModeIcons[i];
String str = toggleModeText[i];
ToggleModeLineInfo lineInfo = new ToggleModeLineInfo(j, str);
modeList.add(lineInfo);
}
return new ToggleModeAdapter(this, modeList);
}
spr_toggleMode.setOnItemSelectedListener(new OnItemSelectedListener(){
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
switch (arg2) {
case 1:
style = 1;
System.out.println("路线是"+routetag);
System.out.println("方向是"+directiondir);
busOnRoute_dir();
break;
case 2:
style = 2;
showStopandprediction();
break;
default:
break;
}
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});