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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:45:27+00:00 2026-06-17T14:45:27+00:00

I have a grid view filled with edittexts. When the user presses a button,

  • 0

I have a grid view filled with edittexts. When the user presses a button, I want to retrieve all the values stored in the edittexts, but I am only getting the first one back.

The grid view is in the fragment_score.xml.

The edit texts in the grid view grid_items.xml

<EditText 
    android:id="@+id/grid_item_edit_text_red"
    android:inputType="number"
    android:layout_width="50dp"
    android:layout_height="50dp"


    />

<EditText 
    android:id="@+id/grid_item_edit_text_blue"
    android:inputType="number"
    android:layout_width="50dp"
    android:layout_height="50dp"

     />

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;


import com.actionbarsherlock.app.SherlockFragment;
import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.Menu;

import android.content.Context;
import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.GridView;

import android.view.View.OnTouchListener;
import android.view.inputmethod.InputMethodManager;

public class RedFragment extends SherlockFragment {


LayoutInflater infl;
GridView mGrid;

String[] etCollection = new String[9];


ImageAdapter adapter;

View mView;


Context mContext;
Button calc;    

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    System.out.println("onCreateView called");
    infl = inflater;
    //super.onCreate(savedInstanceState);
    super.onCreateView(inflater, container, savedInstanceState);
    mView = inflater.inflate(R.layout.fragment_score, container, false);
    mGrid = (GridView) mView.findViewById(R.id.gridViewRed);

    setHasOptionsMenu(true);

    //tView = container.getRootView();
    mContext = mView.getContext();

    for(int j=0;j<9;j++)
    {
        etCollection[j] = "-1";
    }




    adapter = new ImageAdapter(mContext);
    mGrid.setAdapter(adapter);
    Log.e("debug", "here2");
    calc = (Button)mView.findViewById(R.id.calc_red);

    calc.setOnTouchListener(new OnTouchListener(){
        @Override
        public boolean onTouch(View v, MotionEvent event){
            calculate();
            return true;

        }
    });


    return mView;
}







public void getGridVals(){

    Log.v("vals", "Getting grid Vals()");

    for(int i=0;i<9;i++)
    {
        EditText tempText1 = (EditText)mView.findViewById(R.id.grid_item_edit_text_red);
        Log.v("temp text ", "." + tempText1.getText().toString());
                   //this should update etCollection[]
        adapter.getView(i, mView, null);
           //this always prints the value stored in the first textview
        Log.d("etCollection", etCollection[i]);



    }



}

public void setGridVals(int i, String val){

    etCollection[i] = val;


}


public void calculate(){ 
    int[][] pegs = new int[3][3];
    getGridVals();
}



public class ImageAdapter extends BaseAdapter{

    Context context;




    public ImageAdapter(Context context)
    {
        this.context = context;
        etCollection  = new String[getCount()];

    }


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

        View myView = convertView;


        if(convertView == null)
        {
            LayoutInflater li = infl;
            myView= li.inflate(R.layout.grid_items, null);


        }
            ///////////////////////////////
        //this seems to always return the value in the first R.id.grid_item_edit_text_red
        EditText editText = (EditText) myView.findViewById(R.id.grid_item_edit_text_red);
        etCollection[position] = editText.getText().toString();

        return myView;
    }

    @Override
    public int getCount() {

        return 9;
    }



    @Override
    public Object getItem(int position) {
        Log.w("etCollection: " + position , etCollection[position]);
        return etCollection[position];
    }

    @Override
    public long getItemId(int position) {

        return 0;//mGrid.getItemIdAtPosition(position);
    }


}

}

  • 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-17T14:45:28+00:00Added an answer on June 17, 2026 at 2:45 pm

    I fixed it by using text watchers on the edit texts and updating the arrays from there

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

Sidebar

Related Questions

I have a grid view on my page and I want to export it
I have a grid view which contains a button in a template field. I
I have a grid view and I add columns to it by code: //Retrieve
I have a grid filled with notes and I want to be able to
I have a button which adds new row in grid view at button click
In my c# form I have a data grid view where I want to
I have a grid view with below markup and below datasourse (linq query-stored procedure),
I am using vb.net code. I have grid view, please see the code below:
I have a grid view in my main page and I display some data
I have a grid view control in my application. Please see the below code.

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.