2013-05-08 53 views
0
List<String> fetchcategorynames=obj_Categorydb.fetchcategory(); 
CharSequence[] categorynames=fetchcategorynames.toArray(new CharSequence[fetchcategorynames.size()]); 
Log.i(TAG,"Charsequence:"+categorynames.toString());         
AlertDialog.Builder alert_Categoryitem=new AlertDialog.Builder(WorkActivity.this,R.style.cust_dialog); 
alert_Categoryitem.setTitle("Category Names");         
alert_Categoryitem.setItems(categorynames,new DialogInterface.OnClickListener() { 
    @Override 
    public void onClick(DialogInterface dialog, int which) { 
     //how to get the item name 
    } 
}); 
alert_Categoryitem.show(); 
+0

除了代碼之外,你想添加一個問題嗎? – tbkn23 2013-05-08 08:09:36

回答

0

您可以使用此:

alert_Categoryitem.setItems(categorynames,new DialogInterface.OnClickListener() { 
    @Override 
    public void onClick(DialogInterface dialog, int which) { 
     String result = categorynames[which]; 
    } 
}); 

只需使用which爲選定的指標。