我很尴尬地发布这个问题,但我试图在两个小时内更改应用程序的主要活动中的标题,并且令我惊讶的是没有结果。我想:
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更新了代码 –