AlertDialog.Builder 和spinner
来源:互联网 发布:t2雷霆机甲数据 编辑:程序博客网 时间:2024/04/30 18:55
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() {@Overridepublic void onClick(DialogInterface dialog, int which) {// TODO Auto-generated method stubString destination=theDestination.getText().toString();searchName(destination);}}) .setNegativeButton("取消", new DialogInterface.OnClickListener() {@Overridepublic 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(){@Overridepublic 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;}}@Overridepublic void onNothingSelected(AdapterView<?> arg0) {// TODO Auto-generated method stub} });
- AlertDialog.Builder 和spinner
- AlertDialog和AlertDialog.Builder
- 重访AlertDialog和AlertDialog.Builder
- [android]AlertDialog和AlertDialog.Builder
- AlertDialog和AlertDialog.Builder?两者区别
- AlertDialog和AlertDialog.builder(二)
- AlertDialog和AlertDialog.Builder?两者区别
- AlertDialog.Builder和AlertDialog之间的关系
- AlertDialog和AlertDialog.Builder两者区别
- AlertDialog.Builder和Dialog分析
- spinner和AlertDialog一起使用 spinner的小三角和AlertDialog的button区重叠
- AlertDialog.Builder
- AlertDialog.Builder
- AlertDialog.Builder
- AlertDialog.Builder
- AlertDialog.Builder
- AlertDialog和AlertDialog.builder、返回键退出操作
- Android 对话框AlertDialog和AlertDialog.Builder两者的区别
- vim命令使用大全
- Facebooks BigPipe Done in Java
- 如何少花钱又过好日子
- uninstall.sql
- 7.5 魔板
- AlertDialog.Builder 和spinner
- 解析快乐的三个秘诀
- Boost asio的async_write函数
- Linux开机流程分析与Grub引导程序
- 浏览器问题
- 人生哲理小品十篇
- S3C2440LCD控制器与TFT屏的字符和图片的显示
- 生活亦如你所愿
- OpenGL--生成纹理 gluBuild2DMipmaps()与glTexImage2D()的使用方法及区别