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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:28:45+00:00 2026-06-16T01:28:45+00:00

I am creating an android app the UI of my application is below given.

  • 0

I am creating an android app the UI of my application is below given.
On clicking of submit button, I need the selected check box, value and id textview
example size is not checked, cc(radio button) is checked.
records are populated dynamically in list view, but I am not able to make it work.

DemoImage
Checkbox_ProducoptionActivity.java

 public class MainActivity extends Activity implements OnItemClickListener {

    ListView listview; 
       ArrayList<HashMap<String, String>> list_kategori ;
       ProgressDialog pd;   
       ArrayAdapter<Model_checkbox> adapter;
       List<String> idprdoptins = new ArrayList<String>();  
       List<Model_checkbox> nameprdoptn = new ArrayList<Model_checkbox>(); 
       List<Model_checkbox> list = new ArrayList<Model_checkbox>(); 
       Button btn_checkbox; 
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.checkboxproduct_option);
            listview = (ListView)findViewById(R.id.list); 
            btn_checkbox = (Button)findViewById(R.id.btn_productoption);
            // TODO Auto-generated method stub
            String id =CheckLogin(); 
            if (id!=""){  
                 loadproductoption(id); 
            }  
            btn_checkbox.setOnClickListener(new View.OnClickListener() { 
                public void onClick(View view) {

                    for (Model_checkbox m : list) {
                        Log.i("Stack1", m.toString());
                    }
                     Log.d("Stack1",String.valueOf(Model_checkbox.class));
                    Toast.makeText(getApplicationContext(), "ada",Toast.LENGTH_LONG).show();
                } 
            });
        }  

        public void loadproductoption(String id) {
            listproduct task= new listproduct();
            task.execute(id); 
        }

        private class listproduct extends AsyncTask<String, Void, String>{

             protected void onPreExecute(){
                    pd = new ProgressDialog(Checkbox_ProducoptionActivity.this);
                    pd.setMessage("Please wait..");
                    pd.setCancelable(false);
                    pd.show();
             }

            @Override
            protected String doInBackground(String... params) {
                // TODO Auto-generated method stub
                JSONObject jsonResult   = HttpClientCustom.getRequest(Konfigurasi.strUrl+"api-v1/proop?id_user="+ params[0]);
                return jsonResult.toString();
            } 
            protected void onPostExecute(String result){

                JSONObject jsonResponse=null;
                JSONArray jObject=null;

                 list_kategori = new ArrayList<HashMap<String, String>>();  
                 try {
                        jsonResponse    = new JSONObject(new String(result));  
                        if(jsonResponse.getString("status").equals("SUCCESS")) { 
                            if (!jsonResponse.getString("total").equals("0")){ 
                                jObject         = jsonResponse.getJSONArray("resultset"); 
                                for (int i = 0; i < jObject.length(); i++) {  
                                        HashMap<String, String> map = new HashMap<String, String>(); 
                                        map.put("idprd", jObject.getJSONObject(i).getString("id"));
                                        map.put("id_user", jObject.getJSONObject(i).getString("id_user"));
                                        map.put("namepd", jObject.getJSONObject(i).getString("name"));
                                        setListnama(jObject.getJSONObject(i).getString("name"));
                                        list_kategori.add(map);
                                }    
                                adapter  = new Adapter_Checkboxproductoption(Checkbox_ProducoptionActivity.this, getModel());
                                listview.setAdapter(adapter);
                            }  
                             pd.dismiss();    
                        } else if (jsonResponse.getString("status").equals("FAILED")) {
                            pd.dismiss();     
                        }
                } catch (JSONException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }   
                pd.dismiss();    
            }

            private List<Model_checkbox> getModel() { 
                return nameprdoptn;
            } 

            public void setListnama(String name) {
                nameprdoptn.add(new Model_checkbox(name));
            }  
        } 

Model checkbox.java

// public class My modele {

public class Model_checkbox { 

        private String name;
        private boolean selected;
        //private boolean isCcOrIsTo;

        public Model_checkbox(String name) {
            this.name = name;
        }

        public String getName() {
            return name;
        }

        public boolean isSelected() {
            return selected;
        }

        public void setSelected(boolean selected) {
            this.selected = selected;
        } 

        @Override
        public String toString() {
            String selectedString = selected ? "selected" : "not selected";
         //   String value = isCcOrIsTo ? "CC" : "To";
            return name+" -> "+selectedString+ " with value ";
        }
}

MyAdapter.java

// public class MyAdapter extends ArrayAdapter {

class ViewHolder {
    protected TextView text;
    protected CheckBox checkbox; 
}


public class Adapter_Checkboxproductoption extends ArrayAdapter<Model_checkbox> {

        private final List<Model_checkbox> list;
        private final Activity context;
        boolean checkAll_flag = false;
        boolean checkItem_flag = false;

        public Adapter_Checkboxproductoption(Activity context, List<Model_checkbox> list) {
            super(context, R.layout.list_checkbox, list);
            this.context = context;
            this.list = list;
        }

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

            ViewHolder viewHolder = null;
            if (convertView == null) {
                LayoutInflater inflator = context.getLayoutInflater();
                convertView = inflator.inflate(R.layout.list_checkbox, null);

                viewHolder = new ViewHolder();
                viewHolder.text = (TextView) convertView.findViewById(R.id.rowTextView);
                viewHolder.checkbox = (CheckBox) convertView.findViewById(R.id.CheckBox01);
                viewHolder.checkbox.setTag(position); 

                convertView.setTag(viewHolder);
            } else {
                viewHolder = (ViewHolder) convertView.getTag();
            }

            viewHolder.text.setText(list.get(position).getName());
            viewHolder.checkbox.setChecked(list.get(position).isSelected());
            viewHolder.checkbox.setOnClickListener(new OnClickListener() {

                public void onClick(View v) {
                    CheckBox checkbox = (CheckBox) v;
                    int getPosition = (Integer) checkbox.getTag();
                    list.get(getPosition).setSelected(checkbox.isChecked());
                }
            });



            return convertView;
        }
    }

can't work in "Checkbox_ProducoptionActivity.java"
     for (Model_checkbox m : list) {
                        Log.i("Stack1", m.toString());

Can any body help me in getting value and id of selected check box?

  • 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-16T01:28:46+00:00Added an answer on June 16, 2026 at 1:28 am

    For my activity

    public class Checkbox_ProducoptionActivity<country> extends Activity {
    
            ListView list;
            static Context mContext;
            Button btnSave;  
            List<String> val = new ArrayList<String>();
            ArrayList<HashMap<String, String>> list_kategori ; 
            ArrayList<String> stock_list = new ArrayList<String>();
            ArrayList<String> stock2_list = new ArrayList<String>();
            ProgressDialog pd;   
            EfficientAdapter adapter;
            @Override
            public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.checkboxproduct_option);
                list = (ListView) findViewById(R.id.ListView01);
    
                btnSave = (Button)findViewById(R.id.btnSave);
                mContext = this;
                 final String id =CheckLogin(); 
                 if (id!=""){ 
                     loadproductoption(id);
    
                 }
    
                btnSave.setOnClickListener(new View.OnClickListener() {  
                    public void onClick(View v) {
                        SharedPreferences val_shared = getSharedPreferences("CHECKBOX_SHARED", MODE_WORLD_WRITEABLE);
                        SharedPreferences.Editor cleareditor=val_shared.edit();
                        cleareditor.clear();
                        cleareditor.commit();
                     for (int i = 0; i <list.getCount() ; i++) {
                         View vListSortOrder;
                                vListSortOrder=list.getChildAt(i);     
                                try{
                                    TextView textval= (TextView)vListSortOrder.findViewById(R.id.TextView01);
                                    CheckBox ckc=(CheckBox)vListSortOrder.findViewById(R.id.chkbox1);
                                    EditText edit=(EditText)vListSortOrder.findViewById(R.id.txtbox);
                                    if (ckc.isChecked()){
                                          edit.getText().toString();
                                          String temp1 = textval.getText().toString();
                                          Toast.makeText(getApplicationContext(), "fuck"+textval.getText().toString(), Toast.LENGTH_LONG).show();
                                          val.add(temp1);
                                    }   
                                }catch (Exception e) {
                                    // TODO: handle exception
                                }
                        }
                    SharedPreferences customer_ident = getSharedPreferences("CHECKBOX_SHARED", MODE_WORLD_WRITEABLE);
                    SharedPreferences.Editor editor=customer_ident.edit(); 
                    editor.putString("valuecheck", val.toString()); 
                    editor.commit();
                  //  Toast.makeText(getApplicationContext(), "ada "+val, Toast.LENGTH_LONG).show();
                    Intent prdmenuact = new Intent(getApplicationContext(),CreateManageProductActivity.class);
                    prdmenuact.putExtra("idaction", "1"); 
                    startActivity(prdmenuact);
                    finish();
                } 
                }); 
        }
    
        public void loadproductoption(String id) {
            listproduct task= new listproduct();
            task.execute(id); 
        } 
    
        private class listproduct extends AsyncTask<String, Void, String>{
    
             protected void onPreExecute(){
                    pd = new ProgressDialog(Checkbox_ProducoptionActivity.this);
                    pd.setMessage("Please wait..");
                    pd.setCancelable(false);
                    pd.show();
             }
    
            @Override
            protected String doInBackground(String... params) {
                // TODO Auto-generated method stub
                JSONObject jsonResult   = HttpClientCustom.getRequest(Konfigurasi.strUrl+"api-v1/proop?id_user="+ params[0]);
                return jsonResult.toString();
            } 
            protected void onPostExecute(String result){
    
                JSONObject jsonResponse=null; 
                JSONArray jObject=null;
    
                 list_kategori = new ArrayList<HashMap<String, String>>();  
                 try {
                        jsonResponse    = new JSONObject(new String(result));  
                        if(jsonResponse.getString("status").equals("SUCCESS")) { 
                            if (!jsonResponse.getString("total").equals("0")){ 
                                jObject         = jsonResponse.getJSONArray("resultset"); 
                                for (int i = 0; i < jObject.length(); i++) {  
                                        HashMap<String, String> map = new HashMap<String, String>(); 
                                        map.put("idprd", jObject.getJSONObject(i).getString("id"));
                                        map.put("id_user", jObject.getJSONObject(i).getString("id_user"));
                                        map.put("namepd", jObject.getJSONObject(i).getString("name")); 
                                        list_kategori.add(map);   
                                }  
                                adapter = new  EfficientAdapter(Checkbox_ProducoptionActivity.this,list_kategori );
                                list.setAdapter(adapter); 
                            }  
                             pd.dismiss();    
                        } else if (jsonResponse.getString("status").equals("FAILED")) {
                            pd.dismiss();     
                        }
                } catch (JSONException e) {
                 //TODO Auto-generated catch block
                    e.printStackTrace();
                }   
                pd.dismiss();    
            } 
        }
    

    my adpater

    public class EfficientAdapter extends BaseAdapter { 
    
            private Activity activity;
            private ArrayList<HashMap<String, String>> data;
            private  LayoutInflater inflater=null;
            public ImageLoader imageLoader; 
            String priceprd ;
    
            public EfficientAdapter (Activity a, ArrayList<HashMap<String, String>> d) {
                activity = a;
                data=d;
                inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                imageLoader=new ImageLoader(activity.getApplicationContext());
            }
    
            public EfficientAdapter(Runnable runnable,
                    ArrayList<HashMap<String, String>> list_kategori) {
                // TODO Auto-generated constructor stub
            }
    
            public int getCount() {
                //Log.d("country",String.valueOf(data.size()));
                return data.size();
            }
    
            public Object getItem(int position) {
                return position;
            }
    
            public long getItemId(int position) {
                return position;
            }
    
            public View getView(int position, View convertView, ViewGroup parent) {
                final ViewHolder holder;
                if (convertView == null) {
                    convertView = inflater.inflate(R.layout.list_checkbox, parent,
                            false);
                    holder = new ViewHolder();
                    holder.text = (TextView) convertView.findViewById(R.id.TextView01);
                    holder.text2 = (TextView) convertView.findViewById(R.id.TextView02);
                    holder.txt = (EditText) convertView.findViewById(R.id.txtbox);
                    holder.cbox = (CheckBox) convertView.findViewById(R.id.chkbox1);
    
                    convertView.setTag(holder);
                } else {
                    holder = (ViewHolder) convertView.getTag();
                } 
                holder.text.setText( data.get(position).get("idprd"));
                holder.text2.setText(data.get(position).get("namepd"));
                holder.txt.setText("");
                holder.cbox.setChecked(false); 
                return convertView;
            }
    
            public class ViewHolder {
                TextView text;
                TextView text2;
                EditText txt;
                CheckBox cbox;
            }
        }
    
    
    public String[] convert(List<String[]> list1) {
            // TODO Auto-generated method stub
            return null;
        }
    

    adapter to be replaced
    and the model removed
    so to check the value of just using ischecked

    for (int i = 0; i <list.getCount() ; i++) {
                         View vListSortOrder;
                                vListSortOrder=list.getChildAt(i);     
                                try{
                                    TextView textval= (TextView)vListSortOrder.findViewById(R.id.TextView01);
                                    CheckBox ckc=(CheckBox)vListSortOrder.findViewById(R.id.chkbox1);
                                    EditText edit=(EditText)vListSortOrder.findViewById(R.id.txtbox);
                                    if (ckc.isChecked()){
                                          edit.getText().toString();
                                          String temp1 = textval.getText().toString();
                                          Toast.makeText(getApplicationContext(), "fuck"+textval.getText().toString(), Toast.LENGTH_LONG).show();
                                          val.add(temp1);
                                    }   
                                }catch (Exception e) {
                                    // TODO: handle exception
                                }
                        }
    

    and successful

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

Sidebar

Related Questions

I am creating a android app the UI of my application is below given.
I am creating a web application (completely running on the server, no Android App
I'm creating Android application contains 2 buttons, on click on each button play a
I'm creating my first android app and I need to use a service. The
When creating an android app, we need to supply a package name in the
Suppose I am creating an Android application that's like an SMS app. The requirements
I'm creating a simple click counter android app, sound is played when a button
I need to pass data from MYSQL database to android application by creating JSON
We are creating many XML files for a single app in developing android applications;
I'm creating an Android app which must do some web surfing in the background

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.