Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9197825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:09:18+00:00 2026-06-17T22:09:18+00:00

I am having a fragment that send request to server and download json ,

  • 0

I am having a fragment that send request to server and download json , then parse it into a listview , somehow i can’t reach the view properly.below is some part of my apps , this is my first touch on listview with fragment , for some reason i only allow to use Fragment so i choose ‘setAdapter‘ instead of ‘setListAdapter‘ to be my adapter

myfragment.java

 public class gallery extends Fragment {

    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
            // TODO Auto-generated method stub
            View myFragmentView = inflater.inflate(R.layout.tab_frag2_layout,
                    container, false);
            return myFragmentView;
        }

    public void onActivityCreated(Bundle savedInstanceState) {
    .........
    .........
    .........
    setAdapter(colorAdapter);

    }

layout.tab_frag2_layout.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" 
    android:background="#ffffff">

<ListView
    android:id="@android:id/list"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingLeft="@dimen/list_padding"
    android:paddingRight="@dimen/list_padding"
    android:tag="listf" />

</LinearLayout>

My expectation is using

MyListView = (ListView)myFragmentView.findViewById(R.id.list);

to get my view , but it doesn’t work that way…
Now I just want to get my listview and apply

MyListView.setAdapter(colorAdapter) to it

any help would be appreciated, thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T22:09:19+00:00Added an answer on June 17, 2026 at 10:09 pm

    Option1: Since your fragment layout consists of just a simple ListView.
    Consider using

    public class gallery extends ListFragment

    Then you can use this code to get your listview.

    myFragmentView.getListView()

    Option2: As Nickolaus mentioned, you need a custom id if you want to use findViewById.

    android:id=”@+id/listview1″

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having an issue binding my JSON data Object to a listView fragment.
So basically, I have a simple Fragment that uses an AsyncTask to download a
Having trouble with an .htaccess file on WAMP. Works on the live server, but
Having searched regarding this issue beforehand, I can find many discussions regarding dynamically adding
The problem I'm having is that my Bean Validation isn't working as I would
i'm having difficulties understanding the math between the different shader stages. in the fragment
I am testing fragments in Android and I'm having some confusing behavior with Fragment
Hello I am having difficulty changing the visual view of the fragment activity. I
I am using view pager and in that I am having three fragments. In
I'm currently using this code fragment to retrieve the one xml value that will

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.