java - Android FragmentLayout isn't loaded -


i'm beginning android develope , need help. i'm doing navigation using framelayout fragments. xml-files correct (or better say, displayed correct in ide). loading fragments doesn't work. , there no error helps me.

the error everytime fragment loaded, debugger says:

w/pathparser: points far apart 4.000000596046461

the xml basic xml given bei android studio start (the template helloworld-textbox). i'm loading fragment following code:

fragmenttransaction fragmenttransaction = getsupportfragmentmanager().begintransaction(); fragmenttransaction.replace(r.id.fragment_container, new dashboard()); fragmenttransaction.commit(); 

r.id.fragment_container correct 1 (firstly don't have confused , secondly checked twice).

many time , hope there me. if need further information, please request them.

adds: fragment (will changed works):

<framelayout 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="com.david_haintz.virtualdatingcoach.community">  <!-- todo: update blank fragment layout --> <textview     android:layout_width="match_parent"     android:layout_height="match_parent"     android:text="@string/hello_blank_fragment" />  </framelayout> 

main:

<?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.coordinatorlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:fitssystemwindows="true" tools:context="com.david_haintz.virtualdatingcoach.mainactivity">  <android.support.design.widget.appbarlayout     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:theme="@style/apptheme.appbaroverlay">      <android.support.v7.widget.toolbar         android:id="@+id/toolbar"         android:layout_width="match_parent"         android:layout_height="?attr/actionbarsize"         android:background="?attr/colorprimary"         app:popuptheme="@style/apptheme.popupoverlay" />  </android.support.design.widget.appbarlayout>  <framelayout     android:id="@+id/fragment_container"     android:layout_width="match_parent"     android:layout_height="match_parent"></framelayout>  <android.support.design.widget.floatingactionbutton     android:id="@+id/fab"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_gravity="bottom|end"     android:layout_margin="@dimen/fab_margin"     android:src="@android:drawable/ic_dialog_email" />  </android.support.design.widget.coordinatorlayout> 

content_main.xml:

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:context="com.david_haintz.virtualdatingcoach.mainactivity" tools:showin="@layout/app_bar_main">  <textview     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:text="hello world!" /> </relativelayout> 

it’s common issue image in android.

sometimes, when write layout file, want preview result , if layout has imageview want see image giving image resources in xml. beware of that, time set image resource in image view preview purpose, don’t forget remove it. if forget remove it, in runtime image loaded , suck app memory.

it seem fine if image loaded once if sample image on item layout, , use layout in recycler view (listview)? sample image loaded in every single item have in list. multiply size of image, how app becomes memory sucker. made mistake, , fortunately used big image, exception raised.

here example of pre set image resources

 <imageview   android:id="@+id/iv_preview"   android:layout_width="match_parent"   android:layout_height="200dp"   android:layout_below="@+id/tv_title"   android:adjustviewbounds="true"   android:scaletype="centercrop"   android:src="@drawable/budget_preview" /> 

budget_preview.png big image. default activity, app uses around 20mb of memory, enter image description here after open activity 3 items layout, jumped 90mb, scroll little bit, oom raised. enter image description here don’t forget remove android:src after finish preview, , you’ll save memory.

hope it’s useful.

use tools:src instead of android:src preview image in android studio 0 impact on runtime http://tools.android.com/tips/layout-designtime-attributes

resource link:

beware of setting image resource preview in xml android


Comments