0
我的alertdialog不會顯示我的列表視圖中的textview。當我點擊列表視圖時,它只顯示列表視圖字符串的第一個列表。有人可以幫助我!如何讓我的alertdialog顯示listview信息?
package com.example.taxime;
import android.app.AlertDialog;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class FindTaxi extends ListActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final String[] number = getResources().getStringArray(R.array.number);
setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,number));
final String[] taxi = getResources().getStringArray(R.array.taxi);
setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, taxi));
ListView lv = getListView();
lv.setTextFilterEnabled(true);
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
AlertDialog.Builder adb=new AlertDialog.Builder(FindTaxi.this);
int selectedPosition = 0;
adb.setTitle(""+taxi[selectedPosition]);
adb.setMessage("Phone Number: "+number[selectedPosition]);
adb.setPositiveButton(TELEPHONY_SERVICE, null);
adb.setNegativeButton("Cancel", null);
adb.show();
}
});
}
}