Hi,

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");
           Log.d(TAG, "HELLO WORLD " + map.entrySet());
           //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
package gb.org;



    import java.util.Collection;
    import java.util.HashMap;
    import java.util.Iterator;
    import java.util.LinkedHashMap;
    import java.util.Map;
    import java.util.Map.Entry;
    import java.util.Set;

    import android.app.ListActivity;
    import android.content.Context;
    import android.os.Bundle;
    import android.util.Log;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.ArrayAdapter;
    import android.widget.BaseAdapter;
    import android.widget.ImageView;
    import android.widget.ListView;
    import android.widget.TextView;
    import android.widget.Toast;


    //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) {
        Log.d(TAG, "HELLO WORLD INSIDE ADAPTER " + map.entrySet());
        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;
        //iternate over hashmap
    // TODO Auto-generated constructor stub
    }
    @Override
    public View getView(int position, View convertView, ViewGroup
parent) {
    // TODO Auto-generated method stub
       Log.d(TAG, "inside getview  ");
        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() {
        // TODO Auto-generated method stub
        return 0;
    }


    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return null;
    }


    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return 0;
    }
    }  //end of class 2







    private static final String TAG = "Example";



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

    /** Called when the activity is first created. */
    @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");
       Log.d(TAG, "HELLO WORLD " + map.entrySet());
       //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) {
    // TODO Auto-generated method stub
    //super.onListItemClick(l, v, position, id);
    String selection = l.getItemAtPosition(position).toString();
    Toast.makeText(this, selection, Toast.LENGTH_LONG).show();



    }


    } //end of class 1



-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to