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 8925881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:49:10+00:00 2026-06-15T07:49:10+00:00

I have tried for a while now but I still can’t seem to get

  • 0

I have tried for a while now but I still can’t seem to get it right. I can add a custom header to a listview but I can’t add a custom row layout to a list. I want each row in the list to have the layout of the file “listitemrow.xml” but I can’t seem to quite understand how to do that despite reading multiple tutorials.

Here is my code

public class PortfolioFragMent extends android.app.ListFragment{
    private String[] ShareholdingNames;
    private ListView mainListView ;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {

        ListView listView = new ListView(getActivity());
        super.onCreate(savedInstanceState);

        ViewGroup header = (ViewGroup)inflater.inflate(R.layout.listviewheader, listView, false);
        listView.addHeaderView(header, null, false);

        ViewGroup listrow = (ViewGroup)inflater.inflate(R.layout.listitemrow, listView, false);
//listView.add(listitemrow); I want to do something like this

        ArrayAdapter<String> array = new ArrayAdapter<String>(getActivity(),
                android.R.layout.simple_list_item_1);
        setListAdapter(array);
        ShareholdingNames= ShareholdingNames();

        for (String str : ShareholdingNames)
            array.add(str);
        listView.setAdapter(array);
        return listView;
    }

    private String[] ShareholdingNames(){
        ShareholdingNames = new String[Portfolio.getPortfolio().count()];
        for(int i=0; i < Portfolio.getPortfolio().count(); i++){
            ShareholdingNames[i]= Portfolio.getPortfolio().getShareHolding(i).getName();
        }
        return ShareholdingNames;
    }

    public void onListItemClick(ListView l, View v, int position, long id) {
        Intent intent = new Intent(getActivity().getApplicationContext(),
        DetailShareHoldingActivity.class);
        intent.putExtra("new_variable_name","value");
        intent.putExtra("bookPositionInList",position);
        startActivity(intent);  
    }
}
  • 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-15T07:49:11+00:00Added an answer on June 15, 2026 at 7:49 am

    To do so you need to add your own custom adapter and add the line

    ViewGroup listrow = (ViewGroup)inflater.inflate(R.layout.listitemrow, listView, false);
    

    into the adapter’s getView method..

    public class ListAdapter extends ArrayAdapter<Item> {
    
     public ListAdapter(Context context, int textViewResourceId) {
    super(context, textViewResourceId);
    // TODO Auto-generated constructor stub
    }
    
    private List<Item> items;
    
    public ListAdapter(Context context, int resource, List<Item> items) {
    
    super(context, resource, items);
    
    this.items = items;
    
    }
    
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
    
    View v = convertView;
    
    if (v == null) {
    
        LayoutInflater vi;
        vi = LayoutInflater.from(getContext());
        v = vi.inflate(R.layout.listitemrow, listView, false);
    
    }
    
     ...
    return v;
    
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been scratching my head on this for a while now but still
I have been doing a lot of searching and still can't seem to figure
I have been using PHP for a while, but now I am trying to
I have been developing wordpress plugins for a while now and i always seem
i have tried to to load the data to text box, while selecting the
I have been stuck on this for a while. i have tried and I
Have you ever tried learning a language while on a project? I have, and
While digging deeper into the latest release of F# I tried to have it
I have had Delphi 2007 for a while. I tried the Delphi 2009 trial.
Have tried to find solutions for this and can't really come up with anything.

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.