我很尷尬地發佈這個問題,但我試圖在兩個小時內更改應用程序的主要活動中的標題,並且令我驚訝的是沒有結果。我想:
setTitle();
getActionBar().setTitle()
getSupportActionBar().setTitle();
在主要活動中設置標題
每個人都在上面寫的,但他們沒有工作。更令人驚訝的是 - 在其他活動和片段中都很好。只有在這一個。
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_beer);
Utils.checkGpsStatus(this);
Utils.checkNetworkStatus(this);
Location location = SmartLocation.with(this).location().getLastLocation();
if(location != null){
lat = location.getLatitude();
lng = location.getLongitude();
}
ViewPager viewPager = (ViewPager) findViewById(R.id.activity_main_activity_beer);
if (viewPager != null) {
setupViewPager(viewPager);
}
//viewPager.setOffscreenPageLimit(2);
//viewPager.setCurrentItem(1);
tabLayout = (TabLayout) findViewById(R.id.tabs);
tabLayout.setupWithViewPager(viewPager);
}
XML:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainBeerActivity" >
<LinearLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior" >
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="horizontal"
android:background="?attr/colorPrimary"/>
<android.support.v4.view.ViewPager
android:id="@+id/activity_main_activity_beer"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
你可以發佈你的活動代碼以及你的佈局xml文件嗎? – Eenvincible
請發佈您遇到此錯誤的課程。 –
@MohammedAtif更新了代碼 –