我有一个关于用户债务和用户债务的应用程序。主要活动是 TabActivity,用于使用自定义列表切换两个活动。
它看起来像(截图):http: //i.stack.imgur.com/qts1f.png
代码是:
public class MainActivity extends TabActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Resources res = getResources(); // Resource object to get Drawables
TabHost tabHost = getTabHost(); // The activity TabHost
TabHost.TabSpec spec; // Resusable TabSpec for each tab
Intent intent; // Reusable Intent for each tab
TextView tv = (TextView)findViewById(R.id.newDebtHeader);
tv.setBackgroundResource(R.drawable.grad);
tv.setTextColor(Color.BLACK);
tv.setFadingEdgeLength(3);
intent = new Intent().setClass(this, DebtsToMeList.class);
spec = tabHost.newTabSpec("debts_to_me").setIndicator(null, res.getDrawable(R.drawable.ic_tab_debts_to_me)).setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, MyDebtsList.class);
spec = tabHost.newTabSpec("my_debts").setIndicator(null, res.getDrawable(R.drawable.ic_tab_my_debts)).setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(2);
}
}
main.xml 是:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="1dp">
<TextView
android:id="@+id/newDebtHeader"
android:layout_height="24dip"
android:layout_width="fill_parent"
android:gravity="center_vertical|center_horizontal"
android:textStyle="bold"
android:textSize="16dip"
android:text="хДолги">
</TextView>
<TabHost
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp" />
</LinearLayout>
</TabHost>
</LinearLayout>
enter code here
但我不喜欢 TabActivity,我想通过水平手指拖动来更改这两个列表。你能帮我改一下代码吗?