簡體   English   中英

讓 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 方法,但我整個上午都在使用它,但我不明白該怎么做,有人可以告訴我該怎么做嗎

從您的偵聽器中激發意圖以啟動新活動。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM