Listview item not Display in the Fragment Android
up vote
0
down vote
favorite
I have Navigation Drawer with Fragment. I want to Open Fragment on Navigation Drawer. No any Error comes in code but Listview Item Not Display in Fragment. Only Blank Page Display. Following Code. Plzz Help Me.
fragment_blank_fragment_trip2.xml
<LinearLayout 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"
android:orientation="vertical"
tools:context="com.example.administrator.vtsapplication.BlankFragmentTrip2">
<ListView
android:id="@+id/mobile_list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
Activity_listview.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/label"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dip"
android:textSize="16dip"
android:textStyle="bold" >
BlankFragmenttrip2.java
package com.example.administrator.vtsapplication;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class BlankFragmentTrip2 extends Fragment {
public BlankFragmentTrip2() {
// Required empty public constructor
}
ViewGroup vg;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
String mobileArray = {"Android", "IPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X"};
vg = (ViewGroup) inflater.inflate(R.layout.fragment_blank_fragment_trip2, container, false);
ArrayAdapter adapter = new ArrayAdapter<String>(getActivity(), R.layout.activity_listview, mobileArray);
ListView listView = (ListView) vg.findViewById(R.id.mobile_list);
listView.setAdapter(adapter);
return inflater.inflate(R.layout.fragment_blank_fragment_trip2, container, false);
}
}
android xml listview layout fragment
add a comment |
up vote
0
down vote
favorite
I have Navigation Drawer with Fragment. I want to Open Fragment on Navigation Drawer. No any Error comes in code but Listview Item Not Display in Fragment. Only Blank Page Display. Following Code. Plzz Help Me.
fragment_blank_fragment_trip2.xml
<LinearLayout 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"
android:orientation="vertical"
tools:context="com.example.administrator.vtsapplication.BlankFragmentTrip2">
<ListView
android:id="@+id/mobile_list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
Activity_listview.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/label"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dip"
android:textSize="16dip"
android:textStyle="bold" >
BlankFragmenttrip2.java
package com.example.administrator.vtsapplication;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class BlankFragmentTrip2 extends Fragment {
public BlankFragmentTrip2() {
// Required empty public constructor
}
ViewGroup vg;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
String mobileArray = {"Android", "IPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X"};
vg = (ViewGroup) inflater.inflate(R.layout.fragment_blank_fragment_trip2, container, false);
ArrayAdapter adapter = new ArrayAdapter<String>(getActivity(), R.layout.activity_listview, mobileArray);
ListView listView = (ListView) vg.findViewById(R.id.mobile_list);
listView.setAdapter(adapter);
return inflater.inflate(R.layout.fragment_blank_fragment_trip2, container, false);
}
}
android xml listview layout fragment
remove the last line, I think that is returning an empty view. just return thevg
and do not sendViewGroup
as the methodonCreateView()
's return type is onlyView
– Devendra Singh
May 21 '16 at 12:38
Thank You for reply me.
– Monark Patel
May 23 '16 at 2:47
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have Navigation Drawer with Fragment. I want to Open Fragment on Navigation Drawer. No any Error comes in code but Listview Item Not Display in Fragment. Only Blank Page Display. Following Code. Plzz Help Me.
fragment_blank_fragment_trip2.xml
<LinearLayout 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"
android:orientation="vertical"
tools:context="com.example.administrator.vtsapplication.BlankFragmentTrip2">
<ListView
android:id="@+id/mobile_list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
Activity_listview.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/label"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dip"
android:textSize="16dip"
android:textStyle="bold" >
BlankFragmenttrip2.java
package com.example.administrator.vtsapplication;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class BlankFragmentTrip2 extends Fragment {
public BlankFragmentTrip2() {
// Required empty public constructor
}
ViewGroup vg;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
String mobileArray = {"Android", "IPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X"};
vg = (ViewGroup) inflater.inflate(R.layout.fragment_blank_fragment_trip2, container, false);
ArrayAdapter adapter = new ArrayAdapter<String>(getActivity(), R.layout.activity_listview, mobileArray);
ListView listView = (ListView) vg.findViewById(R.id.mobile_list);
listView.setAdapter(adapter);
return inflater.inflate(R.layout.fragment_blank_fragment_trip2, container, false);
}
}
android xml listview layout fragment
I have Navigation Drawer with Fragment. I want to Open Fragment on Navigation Drawer. No any Error comes in code but Listview Item Not Display in Fragment. Only Blank Page Display. Following Code. Plzz Help Me.
fragment_blank_fragment_trip2.xml
<LinearLayout 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"
android:orientation="vertical"
tools:context="com.example.administrator.vtsapplication.BlankFragmentTrip2">
<ListView
android:id="@+id/mobile_list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
Activity_listview.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/label"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dip"
android:textSize="16dip"
android:textStyle="bold" >
BlankFragmenttrip2.java
package com.example.administrator.vtsapplication;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class BlankFragmentTrip2 extends Fragment {
public BlankFragmentTrip2() {
// Required empty public constructor
}
ViewGroup vg;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
String mobileArray = {"Android", "IPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X"};
vg = (ViewGroup) inflater.inflate(R.layout.fragment_blank_fragment_trip2, container, false);
ArrayAdapter adapter = new ArrayAdapter<String>(getActivity(), R.layout.activity_listview, mobileArray);
ListView listView = (ListView) vg.findViewById(R.id.mobile_list);
listView.setAdapter(adapter);
return inflater.inflate(R.layout.fragment_blank_fragment_trip2, container, false);
}
}
android xml listview layout fragment
android xml listview layout fragment
asked May 21 '16 at 12:33
Monark Patel
4711
4711
remove the last line, I think that is returning an empty view. just return thevg
and do not sendViewGroup
as the methodonCreateView()
's return type is onlyView
– Devendra Singh
May 21 '16 at 12:38
Thank You for reply me.
– Monark Patel
May 23 '16 at 2:47
add a comment |
remove the last line, I think that is returning an empty view. just return thevg
and do not sendViewGroup
as the methodonCreateView()
's return type is onlyView
– Devendra Singh
May 21 '16 at 12:38
Thank You for reply me.
– Monark Patel
May 23 '16 at 2:47
remove the last line, I think that is returning an empty view. just return the
vg
and do not send ViewGroup
as the method onCreateView()
's return type is only View
– Devendra Singh
May 21 '16 at 12:38
remove the last line, I think that is returning an empty view. just return the
vg
and do not send ViewGroup
as the method onCreateView()
's return type is only View
– Devendra Singh
May 21 '16 at 12:38
Thank You for reply me.
– Monark Patel
May 23 '16 at 2:47
Thank You for reply me.
– Monark Patel
May 23 '16 at 2:47
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
You should use your
Fragment
as this. You are not returning yourView
.
public class BlankFragmentTrip2 extends Fragment {
String mobileArray = {"Android", "IPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X"};
public BlankFragmentTrip2() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_blank_fragment_trip2, container, false);
ArrayAdapter adapter = new ArrayAdapter<String>(getActivity(), R.layout.activity_listview, mobileArray);
ListView listView = (ListView) rootView.findViewById(R.id.mobile_list);
listView.setAdapter(adapter);
return rootView;
}
}
Thank You for Reply. Its Work and My Problem was solve by using your code.. Thank you.
– Monark Patel
May 23 '16 at 2:46
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
You should use your
Fragment
as this. You are not returning yourView
.
public class BlankFragmentTrip2 extends Fragment {
String mobileArray = {"Android", "IPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X"};
public BlankFragmentTrip2() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_blank_fragment_trip2, container, false);
ArrayAdapter adapter = new ArrayAdapter<String>(getActivity(), R.layout.activity_listview, mobileArray);
ListView listView = (ListView) rootView.findViewById(R.id.mobile_list);
listView.setAdapter(adapter);
return rootView;
}
}
Thank You for Reply. Its Work and My Problem was solve by using your code.. Thank you.
– Monark Patel
May 23 '16 at 2:46
add a comment |
up vote
0
down vote
accepted
You should use your
Fragment
as this. You are not returning yourView
.
public class BlankFragmentTrip2 extends Fragment {
String mobileArray = {"Android", "IPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X"};
public BlankFragmentTrip2() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_blank_fragment_trip2, container, false);
ArrayAdapter adapter = new ArrayAdapter<String>(getActivity(), R.layout.activity_listview, mobileArray);
ListView listView = (ListView) rootView.findViewById(R.id.mobile_list);
listView.setAdapter(adapter);
return rootView;
}
}
Thank You for Reply. Its Work and My Problem was solve by using your code.. Thank you.
– Monark Patel
May 23 '16 at 2:46
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
You should use your
Fragment
as this. You are not returning yourView
.
public class BlankFragmentTrip2 extends Fragment {
String mobileArray = {"Android", "IPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X"};
public BlankFragmentTrip2() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_blank_fragment_trip2, container, false);
ArrayAdapter adapter = new ArrayAdapter<String>(getActivity(), R.layout.activity_listview, mobileArray);
ListView listView = (ListView) rootView.findViewById(R.id.mobile_list);
listView.setAdapter(adapter);
return rootView;
}
}
You should use your
Fragment
as this. You are not returning yourView
.
public class BlankFragmentTrip2 extends Fragment {
String mobileArray = {"Android", "IPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X"};
public BlankFragmentTrip2() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_blank_fragment_trip2, container, false);
ArrayAdapter adapter = new ArrayAdapter<String>(getActivity(), R.layout.activity_listview, mobileArray);
ListView listView = (ListView) rootView.findViewById(R.id.mobile_list);
listView.setAdapter(adapter);
return rootView;
}
}
answered May 21 '16 at 12:38
Jay Rathod RJ
7,92041935
7,92041935
Thank You for Reply. Its Work and My Problem was solve by using your code.. Thank you.
– Monark Patel
May 23 '16 at 2:46
add a comment |
Thank You for Reply. Its Work and My Problem was solve by using your code.. Thank you.
– Monark Patel
May 23 '16 at 2:46
Thank You for Reply. Its Work and My Problem was solve by using your code.. Thank you.
– Monark Patel
May 23 '16 at 2:46
Thank You for Reply. Its Work and My Problem was solve by using your code.. Thank you.
– Monark Patel
May 23 '16 at 2:46
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f37362974%2flistview-item-not-display-in-the-fragment-android%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
remove the last line, I think that is returning an empty view. just return the
vg
and do not sendViewGroup
as the methodonCreateView()
's return type is onlyView
– Devendra Singh
May 21 '16 at 12:38
Thank You for reply me.
– Monark Patel
May 23 '16 at 2:47