Listview item not Display in the Fragment Android
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);
}
}

add a comment |
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);
}
}

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 |
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);
}
}

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);
}
}


asked May 21 '16 at 12:33


Monark PatelMonark Patel
5712
5712
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
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 |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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 |
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 |
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 RJJay Rathod RJ
8,17342138
8,17342138
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.
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