我希望能够点击一个 TextView,然后它将引导我到一个新页面,该页面将显示一个多级可扩展列表。
我创建了可扩展列表,并为其创建了一个新的 MainActivity.java 文件,因为它扩展了与主页不同的内容
我的 list 看起来像这样
<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);
}
});
关于java - 让TextView点击到下一页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33652655/