How to get and set text to an EditText in GridView in Android?
<p>I have a GridView that displays matrix element and each of the element consists of an EditText and a TextView object.</p>

<p>how can I get access to a specific EditText and TextView object in the GridView?</p>

<p>I want to get and set text to EditText and TextView object dynamically. I have developed some code to set text to EditText row+col and to TextView (row, col) but all the EditText show 2 and all TextView show (1,1) Please check my code and help me, I will very thankful to you.  </p>

<pre><code>public class GridAdapter extends BaseAdapter
    {
        Context mContext;

        TextView elementSubscript;
        EditText elementValue ;
        int matrixIndex =0;


        public GridAdapter(Context c)
        {
            mContext = c;
        }

        public View getView(int position, View convertView, ViewGroup parent) 
        {
            // TODO Auto-generated method stub
            View elementLayout;
            if(convertView==null)
            {
                LayoutInflater layoutInflater = getLayoutInflater();
                elementLayout = layoutInflater.inflate(R.layout.matrix_element, null);

                elementSubscript = (TextView)elementLayout.findViewById(R.id.elementSubscript);
                elementValue = (EditText)elementLayout.findViewById(R.id.elementValue);

                for(int row=1; row&lt;=5; row++)
                {
                    for(int col=1; col&lt;=4; col++)
                    {
                        if(position == matrixIndex)
                        {
                            int mIndex =row+col;
                            elementSubscript.setText("( "+row+","+col+" )");
                            elementValue.setText(mIndex+"");

                            matrixIndex++;
                        }

                    }
                }

            }
            else
            {
                elementLayout = convertView;
            }

            return elementLayout;
        }


        public int getCount() 
        {
            // TODO Auto-generated method stub
            return 20;
        }

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

        public long getItemId(int position) 
        {
            // TODO Auto-generated method stub
            return 0;
        }
    }
</code></pre>
