AlertDialog.Builder 和spinner

 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
				
			}  	
        });



 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值