我正在尝试制作一个包含许多笑话的简单应用程序,如果我点击下一个按钮应该导航到下一个文本(笑话),怎么可能在谷歌和这个网站上搜索很多但我不知道,我Textswitcher
也在找,但这不是我真正想要的,请帮助我..
package com.example.sona;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TabHost th=(TabHost) findViewById(android.R.id.tabhost);
th.setup();
TabSpec ts=th.newTabSpec("Tab1");
ts.setContent(R.id.jokes);
ts.setIndicator("Jokes");
th.addTab(ts);
ts=th.newTabSpec("Tab2");
ts.setContent(R.id.memories);
ts.setIndicator("Memories");
th.addTab(ts);
ts=th.newTabSpec("Tab3");
ts.setContent(R.id.About);
ts.setIndicator("About");
th.addTab(ts);
ListView listView=(ListView) findViewById(R.id.list);
String[] values = new String[] { "Every student gEts opportunity to enjoy their student life.. . . . . . But some misS those beautiful moments.. . Those sTupid people are knwn as . . . . . TOPPERS.","Truth of student life- . . First bench student know to how to answer every problem. . . . . . . But the last bench student knows how to face every problem. ",
"Teacher to shere Son Teacher : Babu babu timro gharma sabai vanda sano manche ko cha ????? Reply from ultimate Shere`s son : : Madam madam sabai vanda sano ta Daddy hunu huncha Teacher : Kasari babu ??? Shere's son : daddy jahile mom sanga sutnu huncha ma ta sano xha da nai seperate sutchu but daddy ahile samma ni Mummy sanga sutnu huncha..",
"Android Example List View"
};
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, android.R.id.text1, values);
listView.setAdapter(adapter);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:android1="http://schemas.android.com/apk/res/android"
xmlns:android2="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/sona"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TabHost
android2:id="@android:id/tabhost"
android2:layout_width="match_parent"
android2:layout_height="match_parent"
android2:layout_alignParentLeft="true"
android2:layout_alignParentTop="true" >
<LinearLayout
android2:layout_width="match_parent"
android2:layout_height="match_parent"
android2:orientation="vertical" >
<TabWidget
android2:id="@android:id/tabs"
android2:layout_width="match_parent"
android2:layout_height="wrap_content" >
</TabWidget>
<FrameLayout
android2:id="@android:id/tabcontent"
android2:layout_width="match_parent"
android2:layout_height="match_parent" >
<LinearLayout
android2:id="@+id/jokes"
android2:layout_width="match_parent"
android2:layout_height="match_parent"
android2:orientation="horizontal" >
<ScrollView
android2:id="@+id/scrollView1"
android2:layout_width="wrap_content"
android2:layout_height="match_parent" >
<LinearLayout
android2:layout_width="match_parent"
android2:layout_height="match_parent"
android2:orientation="vertical" >
<ListView
android2:id="@+id/list"
android2:layout_width="match_parent"
android2:layout_height="386dp" >
</ListView>
</LinearLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
android2:id="@+id/memories"
android2:layout_width="match_parent"
android2:layout_height="match_parent"
android:orientation="horizontal">
<ScrollView
android2:id="@+id/scrollView1"
android2:layout_width="wrap_content"
android2:layout_height="match_parent" >
<LinearLayout
android2:layout_width="match_parent"
android2:layout_height="match_parent"
android2:orientation="vertical" >
<ImageView
android2:id="@+id/imageView1"
android2:layout_width="wrap_content"
android2:layout_height="wrap_content"
android2:src="@drawable/sonapic"
/>
<ImageView
android2:id="@+id/imageView2"
android2:layout_width="wrap_content"
android2:layout_height="wrap_content"
android2:src="@drawable/sab" />
<ImageView
android2:id="@+id/imageView3"
android2:layout_width="wrap_content"
android2:layout_height="wrap_content"
android2:src="@drawable/sabb" />
<ImageView
android2:id="@+id/imageView4"
android2:layout_width="wrap_content"
android2:layout_height="wrap_content"
android2:src="@drawable/son" />
</LinearLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
android2:id="@+id/About"
android2:layout_width="match_parent"
android2:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android2:id="@+id/aboutme"
android2:layout_width="wrap_content"
android2:layout_height="wrap_content"
android2:text="Visiting Card:
http://www.minevisitcard.blogspot.com/
My introduction and biodata:
http://nibastuyuu.blogspot.com/" />
</LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
</RelativeLayout>