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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:02:03+00:00 2026-06-01T11:02:03+00:00

In class 1 I have a hashmap which I send to my CustomAdapter. map.put(year,

  • 0

In class 1 I have a hashmap which I send to my CustomAdapter.

map.put("year", "Apple");    
map.put("make", "Mango");     
map.put("model", "Grape");    
map.put("style", "Orange");     
map.put("series", "Peach"); 

//link to my adapter
setListAdapter(new MyCustomAdapter(DynamicLists.this, R.layout.row, map));

But in class 2 my MyCustomAdapter getView function is not getting called, can you help understand why ?

thanks

CODE

//class 1 
public class DynamicLists extends ListActivity { 

   //class 2 
   public class MyCustomAdapter extends BaseAdapter { 
       String my_VALUES;
       public MyCustomAdapter(Context context, int textViewResourceId,
                              HashMap<String, String> map) {

           String[][] array = new String[map.size()][2];
           int count = 0;
           String combined="";
           for(Map.Entry<String, String> entry : map.entrySet()){
               combined=""+entry.getKey()+""+entry.getValue();
               count++;
           }
           my_VALUES = combined;
       }

       @Override
       public View getView(int position, View convertView, ViewGroup parent) {
           View row=convertView;

           if (row==null){
               LayoutInflater inflater=getLayoutInflater();
               row=inflater.inflate(R.layout.row, null);
           }

          TextView label =(TextView)row.findViewById(R.id.blocked);
          label.setText(my_VALUES);

          return row;         
       }

       @Override
       public int getCount() {
           return 0;
       }


       @Override
       public Object getItem(int position) {            
           return null;
       }


      @Override
      public long getItemId(int position) {
          return 0;
      }  
   }  //end of class 2 


   private static final String TAG = "Example";


   public static  HashMap<String, String> map = new HashMap<String, String>(); 

   @Override
   public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     //tie data to list, call constructor MyCustomAdapter 
     //populate the list. ArrayAdapter takes current class, layout and array
     map.put("year", "Apple");    
     map.put("make", "Mango");     
     map.put("model", "Grape");    
     map.put("style", "Orange");     
     map.put("series", "Peach"); 
     //link to my adapter
     setListAdapter(new MyCustomAdapter(DynamicLists.this, R.layout.row, map));         

   }


   @Override
   protected void onListItemClick(ListView l, View v, int position, long id) {
      //super.onListItemClick(l, v, position, id);
      String selection = l.getItemAtPosition(position).toString();
      Toast.makeText(this, selection, Toast.LENGTH_LONG).show();        
   }        

} //end of class 1 
  • 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-01T11:02:05+00:00Added an answer on June 1, 2026 at 11:02 am
    getCount() 
    

    How many items are in the data set represented by this Adapter.
    http://developer.android.com/reference/android/widget/Adapter.html

     @Override
        public int getCount() {
            // TODO Auto-generated method stub
            return size;// more than zero
        }
    

    getItem() must return something

    @Override
        public Object getItem(int position) {
            // TODO Auto-generated method stub
            return my_VALUES;// may be in your case
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class in which i have intialized hashmap in static block. Passing
In my spring application context file, I have something like: <util:map id="someMap" map-class="java.util.HashMap" key-type="java.lang.String"
I have the following class: class DerivedMap extends Hashmap<String,Object> {} Which I use because
I have a Parent class. import java.util.HashMap; import java.util.Map; public class Parent { Map<String,String>
I have a convenience collection class in my Flex project called HashMap, which is
I have a custom model, which internally uses HashMap<String, Object> to store the data.
I have a hashmap with large number of entry's which is serialized.If i make
I have a class which I want to set up as keys in HashMap.
I have a class which I want to persist with OrmLite and it stores
I have a class Foo which overrides equals() and hashCode() properly. I would like

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.