我最近将我的 Android 项目从 eclipse 导入到 Android Studio。我有 3 个 styles.xml 文件:styles.xml、styles.xml (v11) 和 styles.xml (v14)。我不知道那是如何以及何时发生的。
styles.xml (v11) 包括:
<!--
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
Run Code Online (Sandbox Code Playgroud)
styles.xml (v14) 包括:
<!--
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
Run Code Online (Sandbox Code Playgroud)
我想知道它们为什么在这里以及我是否可以删除 v11 和 v14 xml 文件。
我正在尝试使用标签(3个标签)对滑动视图进行编码.我希望每个"页面"都成为一个活动.我正在使用本教程中的代码,但遗憾的是每个"页面"只能有一个片段.
我试图做的是将我的活动转换为片段(但我仍然得到一些NullPointerException).
使用Fragment而不是Activity(我正在使用它:AlarmManager,OnCheckedChangeListener,PackageManager,AlertDialog ......)是否安全?有没有更好的方法来解决我的问题?
谢谢.
================================================== ====================
(更新1)
以下是转换后的片段中的一些代码:
public class TabFragment extends Fragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {
private HashMap<String, String> myMap;
static private TextView usernameView;
private String mUsername;
private String permPassword;
private SharedPreferences pref;
private SharedPreferences prefCheckBox;
private TextView trackTextView;
private TextView logoutTextView;
private TextView settingsTextView;
private CheckBox trackCheckBox;
boolean isTrackingEnabled;
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.activity_home_profile, container, false);
final SessionManager session = new SessionManager(getActivity().getApplicationContext());
myMap = session.getUserDetails();
usernameView = …Run Code Online (Sandbox Code Playgroud)