我成功运行了Activity,但是我看到了scrolltabs上方的标题栏。当我尝试时,我希望删除标题栏:
public class Iphone6Activity extends Activity
我收到错误无法解析方法'getSupportFragmentManager()'
以下是我的主要活动:
package com.hashmi.omar.vodafonestore;
import android.app.Activity;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
public class Iphone6Activity extends ActionBarActivity {
// Declaring Your View and Variables
ViewPager pager;
ViewPagerAdapter_ip6 adapter;
SlidingTabLayout tabs;
CharSequence Titles[]={"Overview","Specifications", "Choose a Bundle"};
int Numboftabs =3;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_iphone6);
// Creating The ViewPagerAdapter and Passing Fragment Manager, Titles for the Tabs and Number Of Tabs.
adapter = new ViewPagerAdapter_ip6(getSupportFragmentManager(),Titles,Numboftabs);
// Assigning ViewPager View and setting the adapter
pager = (ViewPager) findViewById(R.id.ip6pager);
pager.setAdapter(adapter);
// Assigning the Sliding Tab Layout View
tabs = (SlidingTabLayout) findViewById(R.id.ip6tabs);
// Setting the ViewPager for the SlidingTabsLayout
tabs.setViewPager(pager);
}
}
如何删除actionbaractivity?
答案 0 :(得分:2)
ActionBarActivity
已弃用,因此我建议先将其更改为AppCompatActivity
:
public class Iphone6Activity extends AppCompatActivity
并在styles.xml
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
</style>
答案 1 :(得分:0)
:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
this.getActionBar().setTitle("");
return super.onCreateOptionsMenu(menu);
}
你的清单中的:
<activity
android:name="your activity"
android:configChanges="orientation|screenSize"
android:label="Label of your Activity HERE"
android:launchMode="singleTop">
...
选择其中一个,在你的清单中只需将android:label设置为空字符串(如果选择清单方式)
答案 2 :(得分:0)
看看这个问题:Cannot call getSupportFragmentManager() from activity
此外,要从视图中删除标题栏,请更改布局xml或Android清单的主题(这将更改整个应用程序的主题,如果您想在活动中使用自定义工具栏,则可能必须使用工具栏)类似于Theme.AppCompat.Light.NoActionBar。
最后,ActionBarActivity扩展了Activity,因此您根本不需要更改它。