我正在列表视图下方的脚栏中寻找选项卡类型的按钮,但这没有发生。在这里,我向您展示了两种布局,一种具有 Tab Bar,另一种具有 ListView。我不确定我应该在哪个布局中添加按钮以将其放在脚栏中下面是我的列表视图代码和快照:
标签栏.xml
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
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">
<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"/>
</LinearLayout>
</TabHost>
列表项选择.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<include
android:id="@+id/list_item_section_text"
layout="@android:layout/preference_category" />
</LinearLayout>
列表视图.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:minHeight="?android:attr/listPreferredItemHeight"
android:paddingRight="?android:attr/scrollbarSize" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="6dip"
android:layout_marginLeft="0dip"
android:layout_marginRight="6dip"
android:layout_marginTop="6dip"
android:layout_weight="0">
<TextView
android:id="@+id/list_item_entry_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/list_item_entry_summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/list_item_entry_title"
android:layout_below="@id/list_item_entry_title"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary" />
</RelativeLayout>
</LinearLayout>
列表视图.java
public class TestListView extends ListActivity {
/** Called when the activity is first created. */
ArrayList<Item> items = new ArrayList<Item>();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
items.add(new SectionItem("Category 1"));
items.add(new EntryItem("Item 1", "This is item 1.1"));
items.add(new EntryItem("Item 2", "This is item 1.2"));
items.add(new EntryItem("Item 3", "This is item 1.3"));
items.add(new SectionItem("Category 2"));
items.add(new EntryItem("Item 4", "This is item 2.1"));
items.add(new EntryItem("Item 5", "This is item 2.2"));
items.add(new EntryItem("Item 6", "This is item 2.3"));
items.add(new EntryItem("Item 7", "This is item 2.4"));
items.add(new SectionItem("Category 3"));
items.add(new EntryItem("Item 8", "This is item 3.1"));
items.add(new EntryItem("Item 9", "This is item 3.2"));
items.add(new EntryItem("Item 10", "This is item 3.3"));
items.add(new EntryItem("Item 11", "This is item 3.4"));
items.add(new EntryItem("Item 12", "This is item 3.5"));
EntryAdapter adapter = new EntryAdapter(this, items);
EntryAdapter adapter = new EntryAdapter(this, items);
setListAdapter(adapter);
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
if(!items.get(position).isSection()) {
EntryItem item = (EntryItem)items.get(position);
Toast.makeText(this, "You clicked " + item.title , Toast.LENGTH_SHORT).show();
}
super.onListItemClick(l, v, position, id);
}
}
标签栏.java
public class Support extends TabActivity {
//private ImageView mSpinnerImage = null;
//private Animation mAnimation = null;
private Button button = null;
private TextView synctitle = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/*Titlebar + Button*/
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.support);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);
button = (Button) findViewById(R.id.syncbutton);
//mSpinnerImage = (ImageView) findViewById(R.id.spinner_view);
//mAnimation = AnimationUtils.loadAnimation(this, R.anim.rotate_animation);
//synctitle = (TextView) findViewById(R.id.synctitle);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
//button.setVisibility(View.INVISIBLE);
//mSpinnerImage.setVisibility(View.VISIBLE);
//synctitle.setVisibility(View.VISIBLE);
//mSpinnerImage.setAnimation(mAnimation);
//mSpinnerImage.startAnimation(mAnimation);
}
});
/*Titlebar + Button ends*/
/*Tabs*/
Bundle bundle = getIntent().getExtras();
TabHost tabHost = getTabHost();
TabHost.TabSpec spec;
Intent intent;
intent = new Intent().setClass(this, TestListView.class);
spec = tabHost .newTabSpec("some_things")
.setIndicator("Info")
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, TestListView.class);
spec = tabHost .newTabSpec("top_things")
.setIndicator("Log")
.setContent(intent);
tabHost.addTab(spec);
//tabHost.getTabWidget().getChildAt(0).getLayoutParams().height = 85;
//tabHost.getTabWidget().getChildAt(1).getLayoutParams().height = 85;
/*Tabs ends*/
}
}