Android SherlockFragmentActivity错误膨胀类
我正在尝试使用带有库ActionBarSherlock的片段编写一个应用程序 所以,我有一个问题 我的布局:Android SherlockFragmentActivity错误膨胀类,android,actionbarsherlock,inflate-exception,Android,Actionbarsherlock,Inflate Exception,我正在尝试使用带有库ActionBarSherlock的片段编写一个应用程序 所以,我有一个问题 我的布局: <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/main_FrameLayout" android:layout_width="matc
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_FrameLayout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<fragment
class="ru.neverdark.phototools.fragments.TitlesFragment"
android:id="@+id/main_titlesFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
我的标题片段类:
package ru.neverdark.phototools.fragments;
import ru.neverdark.phototools.Constants;
import ru.neverdark.phototools.R;
import ru.neverdark.phototools.log.Log;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import com.actionbarsherlock.app.SherlockListFragment;
public class TitlesFragment extends SherlockListFragment {
boolean mDualPane;
int mCurrentCheckPosition = 0;
final String[] TITLES = getResources().getStringArray(R.array.main_menuTitles);
@Override
public void onActivityCreated(Bundle savedInstanceState) {
Log.message("Enter");
super.onActivityCreated(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(getActivity(),
R.layout.menu_item,
R.id.menuItem_label_title,
TITLES));
View detailsFrame = getActivity().findViewById(R.id.main_detailFragment);
mDualPane = detailsFrame != null && detailsFrame.getVisibility() == View.VISIBLE;
if (savedInstanceState != null) {
mCurrentCheckPosition = savedInstanceState.getInt(Constants.CURRENT_CHOICE, 0);
}
if (mDualPane) {
getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
showDetails(mCurrentCheckPosition);
}
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt(Constants.CURRENT_CHOICE, mCurrentCheckPosition);
}
@Override
public void onListItemClick(ListView listView, View view, int position, long id) {
showDetails(position);
}
private void showDetails(int index) {
mCurrentCheckPosition = index;
if (mDualPane == true) {
getListView().setItemChecked(index, true);
showFragment(index);
} else {
showActivity(index);
}
}
private void showFragment(int index) {
}
private void showActivity(int index) {
}
}
调用setContentView函数时发生异常
提前感谢您的帮助。问题已解决
问题字符串:
final String[] TITLES = getResources().getStringArray(R.array.main_menuTitles);
我将此更改为:
final String[] TITLES = {"test1", "test2"};//getResources().getStringArray(R.array.main_menuTitles);
这对我来说很好
Tarun,谢谢你在调查问题上的帮助。尝试将ActionBar中的
标记更改为
,使用了Sherlock示例文件,效果很好。但是,我尝试了您的建议,但它对我没有帮助:-(其中布局main\u detailFragment
defined??还覆盖了列表片段中的onCreateView和充气菜单项布局。main\u detailFragment在布局大文件夹中的“活动”主布局中定义。
final String[] TITLES = getResources().getStringArray(R.array.main_menuTitles);
final String[] TITLES = {"test1", "test2"};//getResources().getStringArray(R.array.main_menuTitles);