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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:37:13+00:00 2026-05-26T05:37:13+00:00

i have a listview that use a simple adapter. Basically each element consist of

  • 0

i have a listview that use a simple adapter. Basically each element consist of an image, 1 string field and a ratingbar.

ListView element’s layout is in the file element.xml
instead the list view is inside main.xml

The value of the string field can be a number, the word FREE, or the word INSTALLED.

Just close to this field in the element.xml layout there is a label with ID = Price and text value = “Application price”

This is what i get now when i display my list:
“Application price” 4
“Application price” FREE
“Application price” 7
“Application price” INSTALLED
“Application price” FREE

Basically what i would like to do is to check the value of the string field and if it is equal to INSTALLEd the label Price has to be become Invisible to get this result:

“Application price” 4
“Application price” FREE
“Application price” 7
INSTALLED
“Application price” FREE

Do you know how to do that……i red that could be right to extend the method getview of my simple adapter, but i don’t know how…..it’s not clear to me the how this method works and what his parameters stand for…..can you help me or suggest me the right thing to do?

public View getView(int position, View convertView, ViewGroup parent) 
    {
        View view = super.getView(position, convertView, parent);


        TextView costo = (TextView) view.findViewById(R.id.costo);
        TextView prezzo = (TextView) view.findViewById(R.id.appPrezzo);
        if (prezzo.getText().equals("Installed"))
        {
            costo.setVisibility(View.INVISIBLE);
            //view = inflater.inflate(R.layout.elem_applist, null);

        }
        else
        {
            costo.setVisibility(View.VISIBLE);
        }

      return view;

I did it in this way……i don’t know why i can’y comment or vote for your answer Blessemn…..anyway it works, but i didn’t use an inflater….Hope is correct also whithout it 🙂

  • 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-05-26T05:37:14+00:00Added an answer on May 26, 2026 at 5:37 am

    In the getview method is called to return the view representing each row. It is called multiple time even when you scroll the list. The arguments you get

    position -> The row number.
    convertview -> the view representing the row. At beginning its null. But once is rendered
    it wont be null.
    parent -> the parent view

    In the getview method, you MUST return a view to represent the row.

    Heres how a normal getView method looks like

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = mInflater.inflate(R.layout.analytics_row, null);
        TextView mNae = (TextView)convertView.findViewById(R.id.analytic_name);
    
        if(data.get(position).mystring == ""){
            mNae.setText("YES");
        } else {
            mNae.setText("No");
        }       
        return convertView;
    }
    

    Here we just get a view using the inflater and find the textview inside the view.
    We check for a condition and set the text accordingly and return the view.

    There are way better tutorials out there. You should search for custom base adapter.

    If it works for you then there is no problem in using it. As long as you return a valid view the list will work. Inflater is just used to create a view from an xml file.

    But do notice paresh’s answer. As you can see he uses a static class to hold references to a rows internal childs. When the list is first renderedm the getview method is only called the n times where n is the number of visible rows at the moment(not exact). Suppose the 5 rows are visible at a time, the adapter reuses an existing view and just updates the values in them.

    So in his code he check it the convertview is null, if it is he inflates a new row otherwise he uses an existing row with updated values. I recomend you watch this video from Google IO

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

Sidebar

Related Questions

I have a listview that is binded to a ThreadSafeObservableCollection. The background of each
I have learned that when using android:entries with a ListView , it uses android.R.layout.simple_list_item_1
I have a simple contentProvider, a layout with a ListView and a button for
This one should be pretty simple. The use case is that I have a
I have a ListView that is fed by an SQLiteDB. On each row returned,
I have a ListView that uses SimpleAdapter, each row has 2 TextViews, and I
I have a main menu screen with a simple ListView that contains links to
I have ListView that has the following EditItemTemplate: <EditItemTemplate> <tr style=> <td> <asp:LinkButton ID=UpdateButton
I have a ListView that is set up with a MinHeight and a MaxHeight.
I have a ListView that I am populating with items from an ObservableCollection .

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.