让TextView点击到下一页

Make TextView click to next page

我希望能够单击 TextView,然后它将引导我进入一个显示多级可扩展列表的新页面。

我创建了可扩展列表,并为其创建了一个新的 MainActivity.java 文件,因为它扩展了与主页不同的内容

我的清单看起来像这样

<activity
        android:name=".MainActivity"
        android:layout_gravity="center"
        android:label="Home"
        android:theme="@style/AppTheme.NoActionBar" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <!-- name defines the class that handles setting up the Activity
         label will be the title for the activity
         theme defines the theme to use -->
    <activity android:name=".NLevelList"
        android:label="Advanced Search"
        android:theme="@style/AppTheme" />

我知道我需要使用 onClick 侦听器并在 MainActivity 中有一个 onClick 方法,但我整个上午都在做这件事,但我不知道该怎么做,有人可以告诉我该怎么做吗

从您的侦听器发出一个 intent 以启动新的 activity。

myTextView.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        Intent intent = new Intent(MainActivity.this, NLevelList.class);
        startActivity(intent);
    }
});

请参阅可用的文档和培训

http://developer.android.com/training/basics/firstapp/starting-activity.html#RespondToButton