投诉似乎与ListFragment创建视图: public class MedsListActivity extends Activity实现ListSelectionListener {
public static ArrayList<Medication> lm;
private final static MedDetailFragment medDetailFragment = new MedDetailFragment();
private final static MedListFragment medListFragment = new MedListFragment();
private FragmentManager mFragmentManager;
/* (non-Javadoc)
* @see android.app.Activity#onCreate(android.os.Bundle)
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_medlist);
populateMedlist();
addTabs();
}
private void addTabs(){
final ActionBar actionBar = getActionBar();
actionBar.setTitle("RxShare");
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
actionBar.setDisplayShowTitleEnabled(false);
Tab tab = actionBar.newTab().setText(R.string.action_medlist);
MedListFragment mlf = new MedListFragment();
tab.setTabListener(new TabListener(mlf));
actionBar.addTab(tab);
}
...
}
public class MedListFragment extends ListFragment {
private final static String LOG_TAG = MedListFragment.class.getCanonicalName();
private ArrayList<Medication> lm;
ListSelectionListener mListener = null;
int mCurrIdx = -1;
public interface ListSelectionListener {
public void onListSelection(int index);
}
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setHasOptionsMenu(false);
setRetainInstance(true);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
String dataString[] = { "One", "Two", "Three", "Four", "Five", "Six",
"Seven", "Eight", "Nine", "Ten" };
ListAdapter myAdapter = new ArrayAdapter<String>(getActivity(),
android.R.layout.simple_expandable_list_item_1, dataString);
setListAdapter(myAdapter);
return super.onCreateView(inflater, container, savedInstanceState);
}
父活动布局xml(R.layout.activity_medlist)如下:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent" />
这会在Eclipse控制台中产生以下堆栈跟踪:
08-18 17:17:07.914:E / FragmentManager(2303):找不到片段MedListFragment的id 0x7f0a0019(com.rxshare:id / action_medlist)的视图 {40cd9158#0 id = 0x7f0a0019} 08-18 17:17:07.914:E / FragmentManager(2303):活动状态:08-18 17:17:07.924: E / FragmentManager(2303):本地活动40d786c0状态:08-18 17:17:07.934:E / FragmentManager(2303):mResumed = false mStopped = false mFinished = false 08-18 17:17:07.934:E / FragmentManager( 2303):mLoadersStarted = false 08-18 17:17:07.944:E / FragmentManager(2303):mChangingConfigurations = false 08-18 17:17:07.944:E / FragmentManager(2303):mCurrentConfig = {1.0 310mcc260mnc en_US ldltr sw360dp w360dp h567dp 320dpi nrml端口手指 -keyb / v / h -nav / h s.6} 08-18 17:17:07.954:E / FragmentManager(2303):活动碎片40d787b0:08-18 17:17:07.954:E / FragmentManager(2303) :#0:MedListFragment {40cd9158#0 id = 0x7f0a0019} 08-18 17:17:07.964:E / FragmentManager(2303):mFragmentId =#7f0a0019 mContainerId =#7f0a0019 mTag = null 08-18 17:17:07.964:E / FragmentManager(2303):mState = 0 mIndex = 0 mWho = android:fragment:0 mBackStackNesting = 0 08-18 17:17:07.964:E / FragmentManager(2303):mAdded = true mRemoving = false mResumed = false mFromLayout = false mInLayout = false 08-18 17:17:07.974:E / FragmentManager(2303):mHidden = false mDetached = false mMenuVisible = true mHasMenu = false 08-18 17:17:07.974:E / FragmentManager(2303):mRetainInstance = true mRetaining = false mUserVisibleHint = true 08-18 17:17:07.974:E / FragmentManager(2303):mFragmentManager = FragmentManager {40d787b0 in MedsListActivity {40d786c0}} 08-18 17:17:07.974:E / FragmentManager(2303):mActivity =com.rxshare.MedsListActivity@40d786c0 08-18 17:17: 07.984:E / FragmentManager(2303):添加片段:08-18 17:17:07.984:E / FragmentManager(2303):#0:MedListFragment {40cd9158#0 id = 0x7f0a0019} 08-18 17:17:07.994:E / FragmentManager(2303):FragmentManager misc状态:08-18 17:17:07.994:E / FragmentManager(2303):mActivity = com.rxshare.MedsListActivity@40d786c0 08-18 17:17:07.994:E / FragmentManager(2303) :mContainer=android.app.Activity$1@40d78828 08-18 17:17:08.004:E / FragmentManager(2303):mCurState = 2 mStateSaved = false mDestroyed = false 08-18 17:17:08.004:E / FragmentManager(2303) ):查看层次结构:08-18 17:17:08.004:E / FragmentManager(2303):com.android.internal.policy.impl.PhoneWindow $ DecorView {40d792f0 VE .... R ..... ID 0, 0-0,0} 08-18 17:17:08.014:E / FragmentManager(2303):android.widget.LinearLayout {40d799b8 VE ...... ......我。 0,0-0,0} 08-18 17:17:08.024:E / FragmentManager(2303):com.android.internal.widget.ActionBarContainer {40d7a598 V.ED .... ...... ID 0 ,0-0,0#1020359 android:id / action_bar_container} 08-18 17:17:08.024:E / FragmentManager(2303):com.android.internal.widget.ActionBarView {40d7ab80 VE .... .... ..ID 0,0-0,0#102035a android:id / action_bar} 08-18 17:17:08.024:E / FragmentManager(2303):android.widget.LinearLayout {40d7bc98 V ..... C. ......一世。 0,0-0,0} 08-18 17:17:08.034:E / FragmentManager(2303):com.android.internal.widget.ActionBarView $ HomeView {40d7cdb8 V.E ..... ......我。 0,0-0,0} 08-18 17:17:08.034:E / FragmentManager(2303):android.widget.ImageView {40d7d218 G.ED .... ......我。 0,0-0,0#1020246 android:id / up} 08-18 17:17:08.044:E / FragmentManager(2303):android.widget.ImageView {40d7d598 V.ED .... 。一世。 0,0-0,0#102002c android:id / home} 08-18 17:17:08.054:E / FragmentManager(2303):com.android.internal.widget.ActionBarContextView {40d807c0 GE .... ... ID 0,0-0,0#102035b android:id / action_context_bar} 08-18 17:17:08.054:E / FragmentManager(2303):com.android.internal.widget.ScrollingTabContainerView {40d82850 VFED ... 。 ......一世。 0,0-0,0} 08-18 17:17:08.054:E / FragmentManager(2303):android.widget.LinearLayout {40d77120 V.ED .... ......我。 0,0-0,0} 08-18 17:17:08.064:E / FragmentManager(2303):com.android.internal.widget.ScrollingTabContainerView $ TabView {40cdf7e0 VFE ... C. ..S ...我。 0,0-0,0} 08-18 17:17:08.064:E / FragmentManager(2303):android.widget.TextView {40cd8db8 V.ED .... .. S ...我。 0,0-0,0} 08-18 17:17:08.074:E / FragmentManager(2303):android.widget.FrameLayout {40d80d38 V.ED .... ......我。 0,0-0,0#1020002 android:id / content} 08-18 17:17:08.074:E / FragmentManager(2303):android.widget.FrameLayout {40d81dc8 VE ...... ......我。 0,0-0,0#1020011 android:id / tabcontent} 08-18 17:17:08.074:E / FragmentManager(2303):com.android.internal.widget.ActionBarContainer {40d811b8 G.ED .... ..... ID 0,0-0,0#102035c android:id / split_action_bar} 08-18 17:17:08.104:D / AndroidRuntime(2303):关闭VM 08-18 17:17:08.104:W / dalvikvm(2303):threadid = 1:线程退出未捕获异常(组= 0x40a71930)08-18 17:17:08.143:E / AndroidRuntime(2303):致命异常:主08-18 17:17:08.143:E / AndroidRuntime(2303):java.lang.RuntimeException:无法启动活动ComponentInfo {com.rxshare / com.rxshare.MedsListActivity}:java.lang.IllegalArgumentException:找不到id 0x7f0a0019的视图(com.rxshare:id / action_medlist)片段MedListFragment {40cd9158 #0 id = 0x7f0a0019} 08-18 17:17:08.143:E / AndroidRuntime(2303):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)08-18 17:17:08.143:E/AndroidRuntime( 2303):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)08-18 17:17:08.143:E / AndroidRuntime(2303):at android.app.ActivityThread.access $ 600(ActivityThread.java:141) 08-18 17:17:08.143:E / AndroidRuntime(2303):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1234)08-18 17:17:08.143:E / AndroidRuntime(2303):at android.os.Handler.dispatchMessage(Handler.java:99)08-18 17:17:08.143:E / AndroidRuntime(2303):at android.os.Looper.loop(Looper.java:137)08-18 17: 17:08.143:E / AndroidRuntime(2303):在android.app.ActivityThread.main(ActivityThread.java:5041)08-18 17:17:08.143:E/AndroidRuntime(2303):at java.lang.reflect.Method .invokeNative(Native Method)08-18 17:17:08.143:E / AndroidRuntime(2303):at java.lang.reflect.Method.invoke(Method.java:511)08-1 8 17:17:08.143:E / AndroidRuntime(2303):at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:793)08-18 17:17:08.143:E / AndroidRuntime(2303) :at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)08-18 17:17:08.143:E / AndroidRuntime(2303):at dalvik.system.NativeStart.main(Native Method)08- 18 17:17:08.143:E / AndroidRuntime(2303):引起:java.lang.IllegalArgumentException:找不到片段MedListFragment {40cd9158#0 id = 0x7f0a0019}的id 0x7f0a0019(com.rxshare:id / action_medlist)的视图-18 17:17:08.143:E / AndroidRuntime(2303):在android.app.FragmentManagerImpl.moveToState(FragmentManager.java:877)08-18 17:17:08.143:E / AndroidRuntime(2303):at android.app .FragmentManagerImpl.moveToState(FragmentManager.java:1057)08-18 17:17:08.143:E / AndroidRuntime(2303):at android.app.BackStackRecord.run(BackStackRecord.java:682)08-18 17:17:08.143 :E / AndroidRuntime(2303):在android.app.FragmentManagerImpl.execPendingActions(Fragme) ntManager.java:1435)08-18 17:17:08.143:E / AndroidRuntime(2303):在android.app.Activity.performStart(Activity.java:5113)08-18 17:17:08.143:E/AndroidRuntime( 2303):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2153)08-18 17:17:08.143:E / AndroidRuntime(2303):... 11更多