求帮忙,Android将ResideMenu引入fragment中,出错

利索 发布于 2015/11/10 16:13
阅读 228
收藏 0

运行时候闪退代码如下帮忙分析分析错误,怎么改正求指教


11-10 15:56:57.416: E/AndroidRuntime(11739): FATAL EXCEPTION: main
11-10 15:56:57.416: E/AndroidRuntime(11739): Process: com.example.newtour, PID: 11739
11-10 15:56:57.416: E/AndroidRuntime(11739): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.newtour/com.example.newtour.MenuActivity}: java.lang.IllegalArgumentException: No view found for id 0x7f080004 (com.example.newtour:id/fl_left_menu) for fragment LeftMenuFragment{443f5dc8 #0 id=0x7f080004}
11-10 15:56:57.416: E/AndroidRuntime(11739): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2187)
11-10 15:56:57.416: E/AndroidRuntime(11739): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2236)
11-10 15:56:57.416: E/AndroidRuntime(11739): at android.app.ActivityThread.access$800(ActivityThread.java:138)
11-10 15:56:57.416: E/AndroidRuntime(11739): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1199)
11-10 15:56:57.416: E/AndroidRuntime(11739): at android.os.Handler.dispatchMessage(Handler.java:102)
11-10 15:56:57.416: E/AndroidRuntime(11739): at android.os.Looper.loop(Looper.java:136)
11-10 15:56:57.416: E/AndroidRuntime(11739): at android.app.ActivityThread.main(ActivityThread.java:5014)
11-10 15:56:57.416: E/AndroidRuntime(11739): at java.lang.reflect.Method.invokeNative(Native Method)
11-10 15:56:57.416: E/AndroidRuntime(11739): at java.lang.reflect.Method.invoke(Method.java:515)
11-10 15:56:57.416: E/AndroidRuntime(11739): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:805)
11-10 15:56:57.416: E/AndroidRuntime(11739): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:621)
11-10 15:56:57.416: E/AndroidRuntime(11739): at dalvik.system.NativeStart.main(Native Method)
11-10 15:56:57.416: E/AndroidRuntime(11739): Caused by: java.lang.IllegalArgumentException: No view found for id 0x7f080004 (com.example.newtour:id/fl_left_menu) for fragment LeftMenuFragment{443f5dc8 #0 id=0x7f080004}
11-10 15:56:57.416: E/AndroidRuntime(11739): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:919)
11-10 15:56:57.416: E/AndroidRuntime(11739): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
11-10 15:56:57.416: E/AndroidRuntime(11739): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
11-10 15:56:57.416: E/AndroidRuntime(11739): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1460)
11-10 15:56:57.416: E/AndroidRuntime(11739): at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:556)
11-10 15:56:57.416: E/AndroidRuntime(11739): at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1171)
11-10 15:56:57.416: E/AndroidRuntime(11739): at android.app.Activity.performStart(Activity.java:5261)
11-10 15:56:57.416: E/AndroidRuntime(11739): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2160)
11-10 15:56:57.416: E/AndroidRuntime(11739): ... 11 more


ublic class MenuActivity extends FragmentActivity implements OnClickListener  {


private static final String FRAGMENT_LEFT_MENU = "fragment_left_menu";
private static final String FRAGMENT_CONTENT = "fragment_content";
private ResideMenu resideMenu;
private MenuActivity mContext;


/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mContext = this;
setUpMenu();
initFragment();

}
private void initFragment(){
FragmentManager fm=getSupportFragmentManager();
FragmentTransaction transaction=fm.beginTransaction();
transaction.replace(R.id.fl_left_menu, new LeftMenuFragment(),FRAGMENT_LEFT_MENU);
transaction.replace(R.id.fl_mm, new ContentFragment(),FRAGMENT_CONTENT);
transaction.commit();
}
private void setUpMenu() {


// attach to current activity;
resideMenu = new ResideMenu(this);
resideMenu.setBackground(R.drawable.pc_001);//侧滑栏背景图
resideMenu.attachToActivity(this);
resideMenu.setMenuListener(menuListener);


// create menu items;
String titles[] = { "北京", "上海", "广州", "深圳","四川","香港","大连","成都","洛阳","福建","天津","厦门" };
//,"四川","香港","大连","成都","洛阳"
int icon[] = { R.drawable.icon_home, R.drawable.icon_profile,
R.drawable.icon_calendar, R.drawable.icon_settings ,R.drawable.icon_profile
,R.drawable.icon_calendar,R.drawable.icon_profile,R.drawable.icon_profile,R.drawable.icon_calendar
,R.drawable.icon_calendar,R.drawable.icon_calendar,R.drawable.icon_calendar};


for (int i = 0; i < titles.length; i++) {
ResideMenuItem item = new ResideMenuItem(this, icon[i], titles[i]);
item.setOnClickListener(this);
resideMenu.addMenuItem(item);
}


// add gesture operation's ignored views


}

@Override
public void onClick(View view) {
resideMenu.closeMenu();
}


private ResideMenu.OnMenuListener menuListener = new ResideMenu.OnMenuListener() {
@Override
public void openMenu() {

}


@Override
public void closeMenu() {

}
};




@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
return resideMenu.onInterceptTouchEvent(ev)
|| super.dispatchTouchEvent(ev);
}






}


package fragment;


import com.example.newtour.MenuActivity;
import com.example.newtour.R;
import com.example.newtour.ResideMenu;
import com.example.newtour.ResideMenuItem;


import android.view.MotionEvent;
import android.view.View;


public class LeftMenuFragment extends BaseFragment {
private ResideMenu resideMenu;
private MenuActivity mContext;
@Override
public View initViews() {
// TODO Auto-generated method stub
View view=View.inflate(mActivity, R.layout.residemenu_item, null);

return view;
}

}

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/fl_mm"
              android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:background="@android:color/white">


   


</FrameLayout>


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
   
   


</LinearLayout>





加载中
0
vigiles
vigiles
IllegalArgumentException: No view found
利索
具体一点
0
vigiles
vigiles
com.example.newtour:id/fl_left_menu
利索
如何修改呢,求指教
0
vigiles
vigiles
xml里没有这个id
返回顶部
顶部