ArrayList有网址或当我单击列表时移到另一个Activity?

时间:2018-10-15 10:53:07

标签: android android-layout android-fragments arraylist

请需要帮助,这是我第一次在这里问我希望找到我的答案 这是我的Java,称为开放活动,确定。.

public class OpenMainActivity2 extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.word_list);

        // Create a list of words
        final ArrayList<Word> words = new ArrayList<Word>();


        words.add(new Word("9/10", "SmackDown ", R.drawable.smackdown));
        words.add(new Word("8/10", "Raw (Last Show)", R.drawable.rawee));
        words.add(new Word("7/10", "Super Show Down ", R.drawable.supershowdown));
        words.add(new Word("6/10", "UFC 229 FULL ", R.drawable.ufc229));
        words.add(new Word("1/10", "RAW (Last Show) ", R.drawable.rawshowlast));


        // Create an {@link WordAdapter}, whose data source is a list of {@link Word}s. The
        // adapter knows how to create list items for each item in the list.
        WordAdapter adapter = new WordAdapter(this, words, R.color.category_listcolor);

        // Find the {@link ListView} object in the view hierarchy of the {@link Activity}.
        // There should be a {@link ListView} with the view ID called list, which is declared in the
        // word_list.xml layout file.
        ListView listView = findViewById(R.id.list1);

        // Make the {@link ListView} use the {@link WordAdapter} we created above, so that the
        // {@link ListView} will display list items for each {@link Word} in the list.
        listView.setAdapter(adapter);

    }

}

然后 我需要知道如何进入另一个活动,这是每个列表都有自己的活动 要么  我需要知道如何使所有列表具有链接网址,当我单击它时将其移到Google或任何链接,例如Dailymotion。

1 个答案:

答案 0 :(得分:0)

您需要为列表视图设置onClickListener

Persons