Android 如何从上一个Listview中的选定项访问另一个Listview?
我是新手。大家好。我想开发一个应用程序,它首先显示马来西亚的一个州列表,然后当一个州被选中时,另一个显示该州学校名称的列表就会弹出。到目前为止,我已经完成了第一部分。我怎么去第二部分?我做了一些研究,但还是迷路了。非常感谢您的建议、示例和教程链接Android 如何从上一个Listview中的选定项访问另一个Listview?,android,listview,Android,Listview,我是新手。大家好。我想开发一个应用程序,它首先显示马来西亚的一个州列表,然后当一个州被选中时,另一个显示该州学校名称的列表就会弹出。到目前为止,我已经完成了第一部分。我怎么去第二部分?我做了一些研究,但还是迷路了。非常感谢您的建议、示例和教程链接 public class MainActivity extends Activity { //Initialize the array String[] states = { "Federal Territory of Kuala L
public class MainActivity extends Activity {
//Initialize the array
String[] states = { "Federal Territory of Kuala Lumpur", "Federal Territory of Labuan", "Federal Territory of Putrajaya",
"Johor", "Kedah", "Kelantan", "Malacca", "Negeri Sembilan", "Pahang", "Perak", "Perlis", "Penang",
"Sabah", "Sarawak", "Selangor", "Terengganu" };
// Declare the UI components
private ListView statesListView;
private ArrayAdapter arrayAdapter;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Initialize the UI components
statesListView = (ListView) findViewById(R.id.listview);
arrayAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, states);
// By using setAdapter method, you plugged the ListView with adapter
statesListView.setAdapter(arrayAdapter);
}
}
我希望本教程能有所帮助。如果答案满足您的需要,您可以单击答案左侧的勾号接受。