新手来了 大家好。我想开发一个应用程序,首先显示马来西亚的状态列表,然后选择一个州时,另一个列表显示该州的学校名称弹出。到目前为止,我已经完成了第一部分。如何进入第二部分?我已经做了一些研究,但我仍然迷路了。非常感谢建议、示例和教程链接。
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);
}
}