- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
只是想分享我在为客户做的项目中遇到的问题。
每当我进入我的 IntroActivity
并按下按钮将我带到 MenuActivity
时,它就会崩溃。
错误日志如下:
02-16 18:49:49.393 1208-1208/com.wlodsgn.bunbunup E/FragmentManager﹕ No view found for id 0x7f090047 (com.wlodsgn.bunbunup:id/linear) for fragment FmMenu{b1e537f0 #0 id=0x7f090047}
02-16 18:49:49.393 1208-1208/com.wlodsgn.bunbunup E/FragmentManager﹕ Activity state:
02-16 18:49:49.423 1208-1208/com.wlodsgn.bunbunup E/FragmentManager﹕ Local FragmentActivity b1e1d1b8 State:
02-16 18:49:49.423 1208-1208/com.wlodsgn.bunbunup E/FragmentManager﹕ mCreated=falsemResumed=false mStopped=false mReallyStopped=false
02-16 18:49:49.423 1208-1208/com.wlodsgn.bunbunup E/FragmentManager﹕ mLoadersStarted=false
02-16 18:49:49.443 1208-1208/com.wlodsgn.bunbunup E/FragmentManager﹕ FragmentManager misc state:
02-16 18:49:49.443 1208-1208/com.wlodsgn.bunbunup E/FragmentManager﹕ mActivity=com.wlodsgn.bunbunup.MenuActivity@b1e1d1b8
02-16 18:49:49.443 1208-1208/com.wlodsgn.bunbunup E/FragmentManager﹕ mContainer=android.support.v4.app.FragmentActivity$2@b1e1ed08
02-16 18:49:49.453 1208-1208/com.wlodsgn.bunbunup E/FragmentManager﹕ mCurState=1 mStateSaved=false mDestroyed=false
02-16 18:49:49.453 1208-1208/com.wlodsgn.bunbunup E/FragmentManager﹕ View Hierarchy:
02-16 18:49:49.453 1208-1208/com.wlodsgn.bunbunup E/FragmentManager﹕ com.android.internal.policy.impl.PhoneWindow$DecorView{b1e23d08 V.E..... ... 0,0-0,0}
02-16 18:49:49.473 1208-1208/com.wlodsgn.bunbunup E/FragmentManager﹕ android.widget.LinearLayout{b1e24280 V.E..... ... 0,0-0,0}
02-16 18:49:49.473 1208-1208/com.wlodsgn.bunbunup E/FragmentManager﹕ android.view.ViewStub{b1e24da8 G.E..... ... 0,0-0,0 #102030e}
02-16 18:49:49.473 1208-1208/com.wlodsgn.bunbunup E/FragmentManager﹕ android.widget.FrameLayout{b1e25038 V.E..... ... 0,0-0,0}
02-16 18:49:49.473 1208-1208/com.wlodsgn.bunbunup E/FragmentManager﹕ android.support.v7.internal.widget.ActionBarOverlayLayout{b1e2db28 V.E..... ... 0,0-0,0 #7f09002f app:id/decor_content_parent}
02-16 18:49:49.483 1208-1208/com.wlodsgn.bunbunup E/FragmentManager﹕ android.support.v7.internal.widget.NativeActionModeAwareLayout{b1e2f758 V.E..... ... 0,0-0,0 #1020002 android:id/content}
02-16 18:49:49.483 1208-1208/com.wlodsgn.bunbunup E/FragmentManager﹕ [ 02-16 18:49:49.513 1208: 1208 E/FragmentManager ]
android.support.v4.widget.DrawerLayout{b1e2c058 VFE..... ... 0,0-0,0 #7f090042 app:id/drawer_layout}
02-16 18:49:49.513 1208-1208/com.wlodsgn.bunbunup E/FragmentManager﹕ android.widget.LinearLayout{b1e1fa90 V.E..... ... 0,0-0,0}
02-16 18:49:49.523 1208-1208/com.wlodsgn.bunbunup E/FragmentManager﹕ android.support.v4.view.ViewPager{b1e29568 VFED.... ... 0,0-0,0 #7f090043 app:id/pager}
02-16 18:49:49.523 1208-1208/com.wlodsgn.bunbunup E/FragmentManager﹕ android.widget.ListView{b1e44148 VFED.VC. ... 0,0-0,0 #7f090044 app:id/listView1}
02-16 18:49:49.523 1208-1208/com.wlodsgn.bunbunup E/FragmentManager﹕ android.widget.ListView{b1dd80b8 VFED.VC. ... 0,0-0,0 #7f090045 app:id/list_slidermenu}
02-16 18:49:49.523 1208-1208/com.wlodsgn.bunbunup E/FragmentManager﹕ android.support.v7.internal.widget.ActionBarContainer{b1e2fcd0 V.ED.... ... 0,0-0,0 #7f090030 app:id/action_bar_container}
02-16 18:49:49.533 1208-1208/com.wlodsgn.bunbunup E/FragmentManager﹕ android.support.v7.widget.Toolbar{b1e30898 V.E..... ... 0,0-0,0 #7f090031 app:id/action_bar}
02-16 18:49:49.533 1208-1208/com.wlodsgn.bunbunup E/FragmentManager﹕ android.widget.ImageButton{b1e39da8 VFED..C. ... 0,0-0,0}
02-16 18:49:49.533 1208-1208/com.wlodsgn.bunbunup E/FragmentManager﹕ android.widget.TextView{b1e28a60 V.ED.... ... 0,0-0,0}
02-16 18:49:49.533 1208-1208/com.wlodsgn.bunbunup E/FragmentManager﹕ android.support.v7.internal.widget.ActionBarContextView{b1e43a50 G.E..... ... 0,0-0,0 #7f090032 app:id/action_context_bar}
02-16 18:49:49.543 1208-1208/com.wlodsgn.bunbunup D/AndroidRuntime﹕ Shutting down VM
02-16 18:49:49.543 1208-1208/com.wlodsgn.bunbunup W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xb1a87ba8)
02-16 18:49:49.573 1208-1208/com.wlodsgn.bunbunup E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.wlodsgn.bunbunup, PID: 1208
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.wlodsgn.bunbunup/com.wlodsgn.bunbunup.MenuActivity}: java.lang.IllegalArgumentException: No view found for id 0x7f090047 (com.wlodsgn.bunbunup:id/linear) for fragment FmMenu{b1e537f0 #0 id=0x7f090047}
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalArgumentException: No view found for id 0x7f090047 (com.wlodsgn.bunbunup:id/linear) for fragment FmMenu{b1e537f0 #0 id=0x7f090047}
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:882)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1062)
at android.app.BackStackRecord.run(BackStackRecord.java:684)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1447)
at android.app.Activity.performStart(Activity.java:5240)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2168)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
这是我的 MenuActivity.java
错误所在的位置(接近尾部以 if (fragment != null) {
开头:
import java.util.ArrayList;
import java.util.List;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.MenuItemCompat;
import android.support.v4.view.MenuItemCompat.OnActionExpandListener;
import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.SearchView.OnQueryTextListener;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import android.app.Fragment;
import android.app.FragmentManager;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.os.Bundle;
import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.widget.DrawerLayout;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
/**
* Created by WiLo on 2/13/2015.
*/
public class MenuActivity extends ActionBarActivity implements OnQueryTextListener, OnActionExpandListener{
/*private TextView texto;*/
private DrawerLayout mDrawerLayout;
private ListView mDrawerList;
private ActionBarDrawerToggle mDrawerToggle;
// nav drawer title
private CharSequence mDrawerTitle;
// used to store app title
private CharSequence mTitle;
// slide menu items
private String[] navMenuTitles;
private TypedArray navMenuIcons;
private ArrayList<NavDrawerItem> navDrawerItems;
private NavDrawerListAdapter adapter;
String[] categoria = {
"Jeans"
};
int[] imagenes = {
R.drawable.veroxjeans1,
R.drawable.veroxjeans2,
R.drawable.veroxjeans3,
R.drawable.veroxjeans4,
R.drawable.veroxjeans5,
R.drawable.veroxjeans6,
R.drawable.veroxjeans7
};
SectionsPagerAdapter mSectionsPagerAdapter;
ViewPager mViewPager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_menu);
/*texto = (TextView) findViewById(R.id.texto);*/
mTitle = mDrawerTitle = getTitle();
// load slide menu items
navMenuTitles = getResources().getStringArray(R.array.nav_drawer_items);
// nav drawer icons from resources
navMenuIcons = getResources()
.obtainTypedArray(R.array.nav_drawer_icons);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerList = (ListView) findViewById(R.id.list_slidermenu);
navDrawerItems = new ArrayList<NavDrawerItem>();
// agregar un nuevo item al menu deslizante
// Menu
navDrawerItems.add(new NavDrawerItem(navMenuTitles[0], navMenuIcons.getResourceId(0, -1)));
// Contacto
navDrawerItems.add(new NavDrawerItem(navMenuTitles[1], navMenuIcons.getResourceId(1, -1)));
// Catologo
//navDrawerItems.add(new NavDrawerItem(navMenuTitles[2], navMenuIcons.getResourceId(2, -1), true, "Estrenos"));
// old Contacto (Pedidos)
//navDrawerItems.add(new NavDrawerItem(navMenuTitles[3], navMenuIcons.getResourceId(3, -1)));
// Recycle the typed array
navMenuIcons.recycle();
mDrawerList.setOnItemClickListener(new SlideMenuClickListener());
// setting the nav drawer list adapter
adapter = new NavDrawerListAdapter(getApplicationContext(),
navDrawerItems);
mDrawerList.setAdapter(adapter);
// enabling action bar app icon and behaving it as toggle button
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
R.drawable.ic_drawer, //nav menu toggle icon
R.string.app_name, // nav drawer open - description for accessibility
R.string.app_name // nav drawer close - description for accessibility
) {
public void onDrawerClosed(View view) {
getSupportActionBar().setTitle(mTitle);
// calling onPrepareOptionsMenu() to show action bar icons
invalidateOptionsMenu();
}
public void onDrawerOpened(View drawerView) {
getSupportActionBar().setTitle(mDrawerTitle);
// calling onPrepareOptionsMenu() to hide action bar icons
invalidateOptionsMenu();
}
};
mDrawerLayout.setDrawerListener(mDrawerToggle);
if (savedInstanceState == null) {
// on first time display view for first nav item
displayView(0);
}
//lista
ListView lista = (ListView) findViewById(R.id.listView1);
ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, categoria );
lista.setAdapter(adapter);
//galeria de imagenes
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
mViewPager = (ViewPager) findViewById(R.id.pager);
mSectionsPagerAdapter.addfragments(PlaceholderFragment.newInstance(imagenes[0]));
mSectionsPagerAdapter.addfragments(PlaceholderFragment.newInstance(imagenes[1]));
mSectionsPagerAdapter.addfragments(PlaceholderFragment.newInstance(imagenes[2]));
mSectionsPagerAdapter.addfragments(PlaceholderFragment.newInstance(imagenes[3]));
mSectionsPagerAdapter.addfragments(PlaceholderFragment.newInstance(imagenes[4]));
mSectionsPagerAdapter.addfragments(PlaceholderFragment.newInstance(imagenes[5]));
mSectionsPagerAdapter.addfragments(PlaceholderFragment.newInstance(imagenes[6]));
mViewPager.setAdapter(mSectionsPagerAdapter);
}
@Override
public boolean onMenuItemActionExpand(MenuItem menuItem) {
Toast.makeText(getApplicationContext(), "Abriendo Busqueda", Toast.LENGTH_SHORT).show();
return true;
}
@Override
public boolean onMenuItemActionCollapse(MenuItem menuItem) {
Toast.makeText(getApplicationContext(), "Cerrando Busqueda", Toast.LENGTH_SHORT).show();
return true;
}
@Override
public boolean onQueryTextSubmit(String s) {
/*texto.setText("Buscando...\n\n" + s);*/
return false;
}
@Override
public boolean onQueryTextChange(String s) {
/*texto.setText(" \n\n" + s);*/
return false;
}
/**
* Slide menu item click listener
* */
private class SlideMenuClickListener implements
ListView.OnItemClickListener {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
// display view for selected nav drawer item
displayView(position);
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu, menu);
MenuItem searchItem = menu.findItem(R.id.menu3_buscar);
SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
searchView.setOnQueryTextListener(this);
MenuItemCompat.setOnActionExpandListener(searchItem, this);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Pass the event to ActionBarDrawerToggle, if it returns
// true, then it has handled the app icon touch event
if (mDrawerToggle.onOptionsItemSelected(item)) {
return true;
}
// Handle your other action bar items...
return super.onOptionsItemSelected(item);
}
/**
* Diplaying fragment view for selected nav drawer list item
* */
private void displayView(int position) {
// update the main content by replacing fragments
Fragment fragment = null;
switch (position) {
case 0:
fragment = new FmMenu();
break;
case 1:
fragment = new FmContacto();
break;
default:
break;
}
if (fragment != null) {
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction()
.replace(R.id.linear, fragment).commit();
// update selected item and title, then close the drawer
mDrawerList.setItemChecked(position, true);
mDrawerList.setSelection(position);
setTitle(navMenuTitles[position]);
mDrawerLayout.closeDrawer(mDrawerList);
} else {
// error in creating fragment
Log.e("BunBunUp", "MenuActivity - Error cuando se creo el fragment");
}
}
@Override
public void setTitle(CharSequence title) {
mTitle = title;
getSupportActionBar().setTitle(mTitle);
}
/**
* When using the ActionBarDrawerToggle, you must call it during
* onPostCreate() and onConfigurationChanged()...
*/
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
// Sync the toggle state after onRestoreInstanceState has occurred.
mDrawerToggle.syncState();
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// Pass any configuration change to the drawer toggle
mDrawerToggle.onConfigurationChanged(newConfig);
}
public class SectionsPagerAdapter extends FragmentPagerAdapter {
List<android.support.v4.app.Fragment> fragmentos;
public SectionsPagerAdapter(android.support.v4.app.FragmentManager fm) {
super(fm);
fragmentos = new ArrayList<android.support.v4.app.Fragment>();
}
public void addfragments(android.support.v4.app.Fragment xfragment){
fragmentos.add(xfragment);
}
@Override
public android.support.v4.app.Fragment getItem(int position) {
return fragmentos.get(position);
}
@Override
public int getCount() {
return fragmentos.size();
}
}
public static class PlaceholderFragment extends android.support.v4.app.Fragment {
private static final String ARG_IMAGE = "imagen";
private int imagen;
public static PlaceholderFragment newInstance(int imagen) {
PlaceholderFragment fragment = new PlaceholderFragment();
Bundle args = new Bundle();
args.putInt(ARG_IMAGE, imagen);
fragment.setArguments(args);
fragment.setRetainInstance(true);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(getArguments() != null) {
imagen = getArguments().getInt(ARG_IMAGE);
}
}
public PlaceholderFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_menu, container, false);
ImageView imagenView = (ImageView) rootView.findViewById(R.id.imageView1);
imagenView.setImageResource(imagen);
return rootView;
}
}
}
以下是链接到 MenuActivity
的其余文件(如果需要):
FmMenu.java
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
/**
* Created by WiLo on 2/13/2015.
*/
public class FmMenu extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.lay_menufragment, container, false);
return rootView;
}
}
activity_menu.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ff0a393d">
<!-- Linearlayout to display Fragments -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="265dp"
tools:context=".MenuActivity" />
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/listView1"
android:layout_gravity="center_horizontal" />
</LinearLayout>
<!-- Listview to display slider menu -->
<ListView
android:id="@+id/list_slidermenu"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="@color/list_divider"
android:dividerHeight="1dp"
android:listSelector="@drawable/list_selector"
android:background="@color/list_background"/>
</android.support.v4.widget.DrawerLayout>
fragment_menu.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MenuActivity$PlaceholderFragment"
android:id="@+id/linear">
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/imageView1"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
lay_menufragment.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>
新错误日志:
02-17 09:41:20.480 917-917/com.wlodsgn.bunbunup W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xb1ad9ba8)
02-17 09:41:20.560 917-917/com.wlodsgn.bunbunup E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.wlodsgn.bunbunup, PID: 917
java.lang.OutOfMemoryError
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:587)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:422)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:840)
at android.content.res.Resources.loadDrawable(Resources.java:2110)
at android.content.res.Resources.getDrawable(Resources.java:700)
at android.widget.ImageView.resolveUri(ImageView.java:638)
at android.widget.ImageView.setImageResource(ImageView.java:367)
at com.wlodsgn.bunbunup.MenuActivity$PlaceholderFragment.onCreateView(MenuActivity.java:345)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1786)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:947)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1126)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1489)
at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:486)
at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1073)
at android.support.v4.view.ViewPager.populate(ViewPager.java:919)
at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1441)
at android.view.View.measure(View.java:16497)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
at android.view.View.measure(View.java:16497)
at android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:851)
at android.view.View.measure(View.java:16497)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.view.View.measure(View.java:16497)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
at android.support.v7.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:453)
at android.view.View.measure(View.java:16497)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.view.View.measure(View.java:16497)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
at android.view.View.measure(View.java:16497)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2291)
at android.view.View.measure(View.java:16497)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1916)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1113)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1295)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5670)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
at android.view.Choreographer.doCallbacks(Choreographer.java:574)
at android.view.Choreographer.doFrame(Choreographer.java:544)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
需要更多信息,让我知道
如有任何帮助,我们将不胜感激
最佳答案
我想我找到了一些东西。
fragmentManager.beginTransaction()
.replace(R.id.linear, fragment).commit();
如您所见,您尝试用您的 fragment 替换布局 R.id.linear
。但 R.id.linear
是您在 fragment_menu.xml 中使用的 RelativeLayout。您应该将 activity_menu.xml 中的布局替换为当前 fragment 。所以我建议:
fragmentManager.beginTransaction().replace(R.id.container, fragment).commit();
在您的activity_menu.xml中:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ff0a393d">
<!-- Linearlayout to display Fragments -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:id="@+id/container">
编辑:
对于新的错误:你的内存有问题。这通常发生在 ImageViews
被大资源填充时。所以只有一个位置可以使用 ImageView
:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_menu, container, false);
ImageView imagenView = (ImageView) rootView.findViewById(R.id.imageView1);
imagenView.setImageResource(imagen);
return rootView;
}
如您所见,您的 imagenView 由资源 imagen
填充imagenView.setImageResource(imagen);
您可能在那里得到了 OutOfMemoryError
。作为解决方案,试试这个:
try {
imagenView.setImageResource(imagen);
} catch (OutOfMemoryError e) {
//fill your ImageView with something smaller .. maybe a smaller resolution
Log.e("PlaceholderFragment", "Error: OutOfMemoryError")
}
还要检查您的imagen,是否需要高分辨率。
关于java.lang.IllegalArgumentException : No view found for id 0x7f090047 ("project name":id/content) for fragment FmMenu 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28556277/
我在尝试从子文件夹调用 View 时遇到一些错误。首先,这东西能用 Route::get('/', function() { return View::make('sample'); }); 但是当我
我有另一个 View 设置,并准备好等待其viewmodel。我的RelayCommand到达我的“当前” View 模型。从当前的 View 模型显示新 View 的最佳方法是什么? 我一直在阅读,
我有一个 bigquery View ,我想与数据分析师共享,以便他们可以通过 Data Studio 访问其数据。此共享 View 对另一个数据集中的私有(private) View 进行查询,而私
我有 3 个 View ,并希望将它们集成到一个 View 中,以便它们成为这一 View 中的子文件夹。 我怎样才能做到这一点?还是我必须制作一个 View ,然后再次手动添加和配置这些 View
我在沙发数据库中有一些文档,这些文档的字段是不同关联文档的ID数组: { associatedAssets: ["4c67f6241f4a0efb7dc2abc24a004dfe", "270f
我正在开发一个小实用程序 View ,它将嵌入到我们的几个应用程序中。它将位于一个公共(public)图书馆中。 我应该将其作为 ViewModel 以及默认的 View 实现公开,还是作为具有固定
由于我的某些 View 具有相似的功能,因此我希望能够与每个 View 共享相同的 View 模型。我的想法是将 token 传递给viewmodel的构造函数,但这将导致代码中出现许多if和else
我有一个目标 View (蓝色 View 和红色 View 用于左上角位置)。我试图用手指移动这个 View 。如果 View 不旋转,一切都很好。 但当我旋转 View 并移动时,第一次就很好了。但
我收到这个错误, "Attempt to invoke virtual method 'android.view.View android.view.View.getRootView()' on a
我将发布我目前拥有的源代码,然后解释我的问题。 这是我希望过渡发生的窗口 这是关联的 View 模型 public class MainViewModel {
我正在尝试找出我遇到的错误。最初,我的同事只是使用 将 View 添加到 subview 中 [self.view addSubview:someController.view]; 来自当前ViewC
我是 MVVM 的新手,需要一些帮助。 我的应用程序由许多不同的窗口组成,这些窗口显示允许用户编辑业务层中的数据的控件。 目前,每次用户打开这些窗口之一的新实例时,都会从头开始创建一个 ViewMod
我一直在寻找与我类似的问题以找到解决方案,但我真的找不到类似的东西。 我试图使用 asynctask 类从解析中下载帖子数组,在获取帖子后,它应该在我的页面中设置帖子数组,并执行 setAdapter
这个问题在这里已经有了答案: What is local/remote and no-interface view in EJB? (2 个答案) 关闭 9 年前。 我以前理解它的意思是“接口(in
希望这不会太困惑。 我有一个主视图 Controller ( MainView ),在 View 底部有一个堆栈 View ,在堆栈 View 中我有三个 View 。在一个 View 中(我们称之为
我一直在想这个问题,我真的不知道如何正确地将一个 View Controller 管理的 View 添加到另一个 View Controller 的 View 中。 这不起作用,因为 View 没有完
在明显的情况下,我必须将大量文件从一个 View 复制到另一个 View 。要复制的文件名将作为输入给出。有什么想法可以通过脚本实现吗? 谢谢,日语 最佳答案 最简单的方法是使用 clearfsimp
我正在使用完整日历。这里我的问题是,当单击上一个按钮或下一个按钮单击功能时,如何找到月 View 、周 View 或日 View 格式的完整日历。这里正在调用下一个和上一个按钮的自定义代码。因为使用这
我对这两者感到困惑,并试图找出差异,但没有得到我正在寻找的特定内容。 在哪里使用索引 View 而不是普通 View 。 它们之间的一些重要区别。 最佳答案 关键的区别在于物化 View 很好,物化了
我在一个 xib 中有一个 CustomView,在两个不同的 xib 中有两个不同的 View 。我想在一个 CustomeView 中依次显示这两个 View 。我有一个 NSView 对象,它连
我是一名优秀的程序员,十分优秀!