如何从以前的Listview中的选定项目进入另一个Listview?

时间:2013-04-30 02:19:43

标签: android listview

新手在这里。大家问候。我想开发一个应用程序,它首先显示马来西亚的州名单,然后当选择州时,另一个列表显示该州的学校名称弹出。到目前为止,我已经完成了第一部分。我如何进入第二部分?我做了一些研究,但我还是迷路了。建议,示例和教程链接非常感谢。

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

}

1 个答案:

答案 0 :(得分:0)

相关问题