Şu anda sekmeli gezinme uygulanmış bir actionBar'ım var ve şimdi sekmeleri kendileri özelleştirmek istiyorum. Bir metin görünümü ve tıklanabilir bir ImageButton'a sahip olmak için her sekme için özel bir XML düzeni oluşturdum ve bunu ayarlamak için ActionBar.Tab.setCustomView'u kullandım. Sorun, düzen için hiçbir özelliğin herhangi bir etkisinin (hizalama gibi) görünmemesidir. Herhangi bir yardım takdir edilecektir! İşte Custom View for ActionBar.Tab doğru görüntülenmiyor
üretilen ne gösteren bir resimdir: Image of what is being producedMy Özel Sekme Düzeni XML dosyası
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<TextView
android:id="@+id/tab_title"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="@drawable/ic_action_refresh"/>
</RelativeLayout>
İşlem Çubuğu kodu:
final ActionBar actionBar = getActionBar();
//Because there is no 'parent' when navigating from the action bar, the home button for the Action Bar is disabled.
actionBar.setHomeButtonEnabled(false);
//Specify that the actionBar will include a tabbed navigation
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
// Setting up the ViewPager rowingViewPager, attaching the RowingFragmentPagerAdapter and setting up a listener for when the
// user swipes between sections.
rowViewPager = (ViewPager) findViewById(R.id.pager);
rowViewPager.setAdapter(rowAdapter);
rowViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener()
{
@Override
public void onPageSelected(int position)
{
actionBar.setSelectedNavigationItem(position);
}
});
// For loop to add tabs for each fragment to the actionBar
for (int tab_counter = 0; tab_counter < rowAdapter.getCount(); tab_counter++)
{
Tab new_tab = actionBar.newTab();
new_tab.setCustomView(R.layout.custom_tab);
TextView tab_title = (TextView) new_tab.getCustomView().findViewById(R.id.tab_title);
tab_title.setText(rowAdapter.getTabTitle(tab_counter));
new_tab.setTabListener(this);
// Add tab with specified text as well as setting this activity as the TabListener.
actionBar.addTab(new_tab);
}
rowViewPager.setOffscreenPageLimit(2); //Sets the number of off-screen fragments to store and prevent re-load. Will increase if future fragments are added.
}
harika bir soru ama ben alıyorum boş için/çekilebilir üst/sol/alt olarak ekleyin çok basit Bu satırdaki işaretçi istisnası. TextView tab_title = (TextView) new_tab.getCustomView(). FindViewById (R.id.tab_title); herhangi bir yardım? – dsharew