No output from fragments in android. - android

Using fragments for the first time. As fragment in itself an activity, going by the documentation, I think I've written it correctly in the manifest.xml.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/example_fragment"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment class="com.test.methods.ExampleFragment"
android:id="#+id/list"
android:layout_weight="1"
android:layout_width="0px"
android:layout_height="match_parent" />
<FrameLayout android:id="#+id/details" android:layout_weight="1"
android:layout_width="0px"
android:layout_height="match_parent" />
</LinearLayout>
My fragment:
package com.test.methods;
import android.support.v4.app.Fragment;
import android.support.v4.app.ListFragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import com.crumbin.main.R;
public class ExampleFragment extends ListFragment {
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
setListAdapter(new ArrayAdapter<String>(getActivity(),
R.id.list,
Shakespeare.TITLES));
return inflater.inflate(R.layout.example_fragment, container, false);
}
}
My Activity:
package com.test.methods;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
public class DemoUserActivity extends FragmentActivity{
protected void OnCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
if (savedInstanceState == null)
{
ExampleFragment details = new ExampleFragment();
details.setArguments(getIntent().getExtras());
getSupportFragmentManager().beginTransaction().add(
android.R.id.content,details).commit();
}
}
}
My intent:
intent = new Intent().setClass(this, DemoUserActivity.class);
spec = tabHost.newTabSpec("list").setIndicator("FragmentTest",
res.getDrawable(R.drawable.icon_list_tab))
.setContent(intent);
tabHost.addTab(spec);
I get no output out of this. I tried debugging but it is not even reaching my activity file.

No Activity is different thing, and Fragment is different, you can use these to create your application moduler, and replace one with another with minimum efforts, but can not use as a replacement of other, if You want to use a fragment, you need to declare an activity, in that activity you need to add your fragment, individual fragment without Activity can not be used.

Related

Android SDK error: Trying instantiate a class that is not a fragment

I am hardly trying to create a simple application with a top menu and a changeable view below (by pressing the buttons in the menu fragment we change the view of the fragment below).
So, I have 2 fragments inside the main view but when trying to run the application in the emulator I get an error like:
Cause by android.app (bla bla bla, piece of crap Eclipse doesn't even allow copying the errors):
Trying to instantiate a class com.example.android.topmenu that is not a fragment
So, these are my XML layouts:
main.xml
<?xml version="1.0" encoding="utf-8"?>
<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" >
<fragment
android:id="#+id/menuFragment"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:name="com.example.android.topmenu" >
</fragment>
<fragment
android:id="#+id/contentFragment"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:name="com.example.android.bottomcontent" >
</fragment>
</LinearLayout>
topmenu.xml
<?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="horizontal" >
<Button
android:id="#+id/Button1"
android:layout_width="wrap_content"
android:layout_height="match_parent" />
</LinearLayout>
bottom_content.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
android:orientation="vertical">
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#+string/content_text" />
</LinearLayout>
and these are the classes for the main activity and the fragments
main_activity
package com.example.android;
import com.example.android.R;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
public class OLife extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
// The activity is being created
super.onCreate(savedInstanceState);
// Set view
setContentView(R.layout.main);
}
#Override
protected void onDestroy() {
super.onDestroy();
// The activity is about to be destroyed.
super.onDestroy();
// Stop method tracing that the activity started during onCreate()
android.os.Debug.stopMethodTracing();
}
}
topmenu
package com.example.android;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class OLifeMenu extends Fragment {
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.topmenu, container, false);
return view;
}
}
bottomcontent
package com.example.android;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class OLifeMain extends Fragment {
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.bottom_content, container, false);
return view;
}
#Override
public void onAttach(Activity activity) {
super.onAttach(activity);
}
}
You should be using FragmentActivity instead of Activity that is because you are using support Fragments and multiple Fragments in your activity main
Edit
You can now use the Appcompat support library and extends AppCompatActivity to support toolbar and fragment for lower api.
In my case it turned out, I was doing stuff in onCreate in the wrong order:
setContentView(R.layout.activity_qr_code_scan);
super.onCreate(savedInstanceState);
instead of
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_qr_code_scan);
As you are using fragments in your layout and I suggest you to extend your class from fragment or fragment activity.

Call an activity from a listViewItem Without losing the tabNavigation

I'm noob on android development, and im trying to do a simple app, for details about certain products and stuff.
i have the the following layout:
<android.support.v4.app.FragmentTabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0"/>
<FrameLayout
android:id="#+android:id/realtabcontent"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<TabWidget
android:id="#android:id/tabs"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
/>
</LinearLayout>
</android.support.v4.app.FragmentTabHost>
There are 2 tabs on that tabHost navigation, each one extends fragment like this
package co.com.smartmedia.vademecumtg;
import co.com.smartmedia.vademecumtg.R;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class LineasTab extends Fragment {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.tab2, container, false);
}
}
In the first tab of that navigation i have a listView, and each item of that list, must call another activity that will show details about it.
im calling a new activity by calling this method from an itemClickListener:
public void intentForMedView(int pos){
Log.w("debbuging", "start");
Intent intent = new Intent(getActivity().getApplicationContext(), MedViewActivity.class);
intent.putExtra(EXTRA_MEDTITLE, array_sort.get(pos).getNombre());
intent.putExtra(EXTRA_MEDCONTENT, array_sort.get(pos).getLinea());
Log.w("debbuging", "send intent"+intent);
startActivity(intent);
}
and the activity that i'm calling is the following:
package co.com.smartmedia.vademecumtg;
import co.com.smartmedia.vademecumtg.R;
import android.app.Activity;
import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
public class MedViewActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_med_view);
Intent intent = getIntent();
String title = intent.getStringExtra(MedicamentosTab.EXTRA_MEDTITLE);
setTitle(title);
TextView text = (TextView) findViewById(R.id.text);
String lineName = intent.getStringExtra(MedicamentosTab.EXTRA_MEDCONTENT);
text.setText(lineName);
}
}
My problem is:
When the detail activity is shown, my navigation Disappears (the tabHost navigation), and i don't want it....
some tips or ways to do it ?
thaks...
I got the answer now, The way to accomplish this architecture, is to use FragmentTransaction
http://developer.android.com/guide/components/fragments.html
Cause it isn't necessary another activity... just play with the fragments of the UI.
FragmentManager fragmentManager = getFragmentManager()
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
And take care with the android version cause android.support.v4.app.FragmentManager cannot cast to the android.app.FragmentManager
Hope this be usefull

Facing Issues when working with fragment

I have to create an application in which I have to work with Fragment.
In the MainActivity, there is a webView. From the SecondActivity I
have starting using Fragment.
Here is the code of SecondActivity:
package com.dev.testapp;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.view.View;
public class Second extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.second);
}
public void choosefragment(View view) {
Fragment fg;
if(view == findViewById(R.id.secondbtn2)) {
fg = new SecondFragment();
}
else
{
fg = new FirstFragment();
}
FragmentManager fm = getFragmentManager();
FragmentTransaction fragmentTransaction = fm.beginTransaction();
fragmentTransaction.replace(R.id.frag1, fg);
fragmentTransaction.commit();
}
}
Hhere is its second.xml file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#ffffff" >
<Button
android:id="#+id/secondbtn1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="first fragment"
android:onClick="chooseFragment" />
<Button
android:id="#+id/secondbtn2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="second fragment"
android:onClick="chooseFragment"/>
<fragment
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:name="com.dev.testapp.fragment1"
android:id="#+id/frag1"
/>
</LinearLayout>
After that I created two more classes for Fragments as it is required
code of FirstFragment:
package com.dev.testapp;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class FirstFragment extends Fragment{
public View onCreate(LayoutInflater inflater,
ViewGroup container , Bundle savedInstanceState) {
//Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment1,container, false);
}
}
And here is the SecondFragment:
package com.dev.testapp;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class SecondFragment extends Fragment{
public View onCreate(LayoutInflater inflater,
ViewGroup container , Bundle savedInstanceState) {
//Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment2,container, false);
}
}
When I am done with all this, my SecondActivity is showing an error that I don't know how to handle:
As noted in previous answers, your problem is incorrect Fragment library for FirstFragment.
Change line 5 of FirstFragment.java:
import android.support.v4.app.Fragment;
to:
import android.app.Fragment;
Your second fragment is of the type android.app.Fragment while your first fragment is android.support.v4.app.Fragment.
your activity use this import android.app.Fragment;
your fragment is import android.support.v4.app.Fragment;
So you either have both extending the Fragment in the app package or in the support library

How to switch between fragments during onclick?

I have a project I'm trying to do. I ran into a little issue and I'm not sure how to get around it. Below is an image of the application so far.
What I would like it to do is when the user onclicks one of the list items, the part which says "Hello! It's Fragment2" changes to a new xml which I declared in the app. So if I click the ATO listItem, then the fragment on the right side should change to something like "Hello! It's ATO Fragment"
Here is my code so far:
AndroidListFragmentActivity:
package com.exercise.AndroidListFragment;
import android.app.Activity;
import android.os.Bundle;
public class AndroidListFragmentActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
Fragment2:
package com.exercise.AndroidListFragment;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class Fragment2 extends Fragment {
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// TODO Auto-generated method stub
return inflater.inflate(R.layout.fragment2, container, false);
}
}
MyListFragment1:
package com.exercise.AndroidListFragment;
import android.app.ListFragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.Toast;
public class MyListFragment1 extends ListFragment {
String[] options ={
"ATO",
"BETA",
"DELT",
"PHI DELT",
"SAE",
"SIG NU",
"FIJI",
"SIG CHI",
"PHI PSI"
};
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ListAdapter myListAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, options);
setListAdapter(myListAdapter);
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.listfragment1, container, false);
}
#Override
public void onListItemClick(ListView l, View v, int position, long id) {
// TODO Auto-generated method stub
Toast.makeText(getActivity(), getListView().getItemAtPosition(position).toString(), Toast.LENGTH_LONG).show();
}
}
Fragment2.xml
<?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" >
<TextView
android:id="#+id/fragment2text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hello! It's Fragment2" />
</LinearLayout>
listfragment1.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"
android:paddingLeft="8dp"
android:paddingRight="8dp">
<ListView android:id="#id/android:list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:drawSelectorOnTop="false"/>
<TextView android:id="#id/android:empty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="No data"/>
</LinearLayout>
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<fragment
android:name="com.exercise.AndroidListFragment.MyListFragment1"
android:id="#+id/fragment1"
android:layout_weight="1"
android:layout_width="0px"
android:layout_height="match_parent" />
<fragment
android:name="com.exercise.AndroidListFragment.Fragment2"
android:id="#+id/fragment2"
android:layout_weight="2"
android:layout_width="0px"
android:layout_height="match_parent" />
</LinearLayout>
Not sure what's the minimal fix to get your code working, but have you looked at using a Navigation Drawer to switch between the fragments? It looks to me like the example in the official docs matches pretty much exactly what you want to achieve.
A key is to have some kind of container for the currently displayed fragment (instead of using <fragment> like in your XML). For example:
<FrameLayout
android:id="#+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Then, switching fragments goes something like this:
Fragment fragment = new Fragment2();
// Insert the fragment by replacing any existing fragment
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction()
.replace(R.id.content_frame, fragment)
.commit();
Further reading: Add a Fragment to an Activity at Runtime in Android developer docs.
private void openFragment (int number) {
Fragment fragment = new Fragment();
switch (number) {
case FRAGMENT_1:
fragment = new *Fragment1*();
break;
case FRAGMENT_2:
fragment = new *Fragment2*();
break;
}
getSupportFragmentManager().beginTransaction()
.replace(R.id.fragment_frame, fragment)
.commit();
}

Fragment is not covering entire screen

please help
When I run my ListFragment actitivy and click on a fragment (either Buick or Mazda), the layout of the fragment I clicked on is supposed to replace and cover the entire screen but the
container containing the list of cars stays on the screen and my fragment layout is shown below it. How can I make my fragment's layout replace the entire screen?
I couldn't post my AVD image showing the screen because I don't have enough reputatons to do
but the screen was showing as below when I clicked on the first item on the list.
Buick
Mazda
Hello! It's a Buick
my Mainactivity
package in.cars.demo;
import android.app.Activity;
import android.os.Bundle;
public class CarsMainActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
My ListFragment activity
package in.cars.demo;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.app.ListFragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.Toast;
public class CarsList extends ListFragment {
String[] cars = new String[] { "Buick", "Mazda" };
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ListAdapter myListAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, cars);
setListAdapter(myListAdapter);
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.cars_container, container, false);
}
#Override
public void onListItemClick(ListView l, View v, int position, long id) {
Toast.makeText(getActivity(), getListView().getItemAtPosition(position).toString(), Toast.LENGTH_LONG).show();
switch (position) {
case 0:
Fragment fragment1 = new Fragment1();
FragmentTransaction transaction1 = getFragmentManager().beginTransaction();
transaction1.replace(R.id.car_fragment, fragment1);
transaction1.addToBackStack(null);
transaction1.commit();
break;
case 1:
Fragment fragment2 = new Fragment2();
FragmentTransaction transaction2 = getFragmentManager().beginTransaction();
transaction2.replace(R.id.car_fragment, fragment2);
transaction2.addToBackStack(null);
transaction2.commit();
break;
}
}
}
Fragment1
package in.cars.demo;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class Fragment1 extends Fragment {
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment1, container, false);
}
}
Fragment2
package in.cars.demo;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class Fragment2 extends Fragment {
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment2, container, false);
}
}
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<fragment
android:id="#+id/car_fragment"
android:name="in.cars.demo.CarsList"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
cars_container.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"
android:paddingLeft="4dp"
android:paddingRight="4dp">
<ListView android:id="#id/android:list"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"/>
</LinearLayout>
fragment1.xml
<?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" >
<TextView
android:id="#+id/frag1TV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hello! It's a Buick" />
</LinearLayout>
fragment2.xml
<?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" >
<TextView
android:id="#+id/frag2TV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hello! It's a Mazda" />
</LinearLayout>
The problem is that you set the layout_height of your fragment to wrap_content in your main.xml. The visible size will be reduced to the actual size of the fragment.
Change it to match_parent to fill the whole screen:
...
<fragment
android:id="#+id/car_fragment"
android:name="in.cars.demo.CarsList"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
...
Furthermore use match_parent instead of fill_parent in apps with API Level 8+. See this question for more information.
Edit:
You have to change the container for the Fragments. The Fragment set with the tag will be static. Every fragment will be set in addition to this container. To have a dynamic approach use a FrameLayout. Now you can replace the fragment which was in there before.
...
<FrameLayout
android:id="#+id/car_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
...
To show your CarsList you have to do a Fragment transaction in your Activity.
getFragmentManager() / getSupportFragmentManager()
.beginTransaction()
.replace(R.id.car_fragment, new CarsList())
.addToBackstack(null)
.commit();
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:clickable="true"
android:orientation="vertical">
Try to setUp a color background to your fragment. In this way the background covers the entire space.
It is a little bit late, but maybe I will help someone else. The problem is with 'fragment' in your activity xml layout file (main.xml). You have to change:
<fragment
android:id="#+id/car_fragment"
android:name="in.cars.demo.CarsList"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
to
<fragment
android:id="#+id/car_fragment"
android:name="in.cars.demo.CarsList"
android:layout_width="match_parent"
android:layout_height="match_parent"/>

Categories

Resources