Hi all!

I have a little ListView in custom ListActivity with following shape in
onCreate():

    [ListElement 0]:
       [TextView: String a]
       [EditView: String b]
    [ListElement 1]:
       [TextView: String x]
       [EditView: String y]

When perform a click in any of these EditViews (which will have listeners),
something strange happens:

    [ListElement 1]:
       [TextView: String x]
       [EditView: String y]
    [ListElement 0]:
       [TextView: String a]
       [EditView: String b]

but when BACK button of emulator is pressed, the original layout back;

Any Ideas for this behaviour?

Below, i put the code of overrided method in my custom ListAdapter
(getView()) and the ListActivity
launched

ListActivity:

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        //setting bundles to edit new IP and Port
        Bundle bundle =
getIntent().getExtras()!=null?getIntent().getExtras():null;

setIp(!(bundle.equals(null))?bundle.getString(StartActivity.MY_IP):null);

setPort(!(bundle.equals(null))?bundle.getInt(StartActivity.MY_PORT):null);

        //setting list
        setContentView(R.layout.list_layout);

        //now set Edit fields
        try {
            setListAdapter(new OSCLayoutAdapter(this,
getViewWithResources()));
        } catch (Exception e) {
            Log.d(TAG, "cannot possible to set List of Edit Fields ", e);
        }
    }

Overrided method in ListAdapter:

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

            if(v==null){
                LayoutInflater inflater = (LayoutInflater)
getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                v = inflater.inflate(R.layout.basic_edit_layout, null);
                TagsHolder tag = new TagsHolder();
                ViewHolder views = new ViewHolder();

                Log.d(TAG, "Configuring View "+v.toString());
                Log.w(TAG, "    Setting View Tags ");
                switch (getItemViewType(position)) {
                case OSCLayoutOrder.EDIT_IP:
                    Log.w(TAG, "    Setting  sub title tag");
                    tag.text = "Set new IP";
                    Log.w(TAG, "    Setting  OSC value tag");
                    tag.oscContent = OSCConfigActivity.getIP();
                    break;
                case OSCLayoutOrder.EDIT_PORT:
                    Log.w(TAG, "    Setting  sub title tag");
                    tag.text = "Set new Port";
                    Log.w(TAG, "    Setting  OSC value tag");
                    tag.oscContent =
String.valueOf(OSCConfigActivity.getPort());
                    break;
                }

                v.setTag(tag);

                try{

                    Log.i(TAG, "    Tags: "+tag.text+", "+tag.oscContent);

                    //TODO populate Edit fields according tags
                    views.textView = (TextView)
v.findViewById(R.id.textView);
                    views.editText = (EditText)
v.findViewById(R.id.editText);

                    Log.d(TAG, "Setting children views according tags...");
                    views.textView.setText(tag.text);
                    views.editText.setText(tag.oscContent);
                    views.editText.setTextColor(Color.DKGRAY);

                    Log.d(TAG, "Setting children listeners...");
                }
                catch (Exception e) {
                    Log.e(TAG, "not possible to populate the View");
                    return v;
                }
            }
            return v;
        }
Thanks!

-- 
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