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

  • Home
  • SEARCH
  • 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 7546521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:13:13+00:00 2026-05-30T09:13:13+00:00

i have problem getting text from edittext inside listview when im in last edittext

  • 0

i have problem getting text from edittext inside listview when im in last edittext in the list problem in getting data of that edittext ,because when change focus of that edittext onfocuschangelistner is not getting call and data of that edittext is not store in my collection variable .

So any one have any solution plz suggest me

My code is here

    public class YourAdapter extends SimpleAdapter {

    protected static final String TAG = null;
    ArrayList<HashMap<String, String>> c = new ArrayList<HashMap<String, String>>();
    Context context;
    JSONArray getArray_Meter_Reading;
    HashMap<String, String> previous_Meter_Reading;
    ArrayList<HashMap<String, Integer>> getReading = new ArrayList<HashMap<String, Integer>>();
    Map<String,Integer> CurrentReading  = new HashMap<String, Integer>();
    int i, previousMeterReading, CurrentMeterReading, Cumulative;
    View v;
    EditText Caption;
    public static HashMap<Integer, String> myList = new HashMap<Integer, String>();

    public YourAdapter(Context context, int layout,
            ArrayList<HashMap<String, String>> c, String[] from, int[] to,
            JSONArray getArray_Meter_Reading) {
        super(context, c, layout, from, to);
        this.c = c;
        this.context = context;
        this.v = null;
        this.Caption = null;
        this.getArray_Meter_Reading = getArray_Meter_Reading;

        for (i = 0; i < getArray_Meter_Reading.length(); i++) {
            myList.put(i, "");
        }

    }

    public View getView(int position, View convertView, ViewGroup parent) {
        View view = super.getView(position, convertView, parent);
        final EditText ed_Current = (EditText) view
                .findViewById(R.id.ed_Current);
        ed_Current.setTag(position);

        ed_Current.setOnFocusChangeListener(new View.OnFocusChangeListener() {

            public void onFocusChange(View arg0, boolean arg1) {

                int tag1 = (Integer) arg0.getTag();
                myList.put(tag1, ed_Current.getText().toString().trim());
                previous_Meter_Reading = new HashMap<String, String>();


                if (v == null) {
                    v = arg0;

                    int tag = (Integer) arg0.getTag();
                    Caption = (EditText) arg0;

                    previous_Meter_Reading = c.get(tag);
                    String getPreviousReading = previous_Meter_Reading
                            .get("previousMeterReading");
                    String CumulativeIndex = previous_Meter_Reading
                            .get("Cumulative");
                    previousMeterReading = Integer.parseInt(getPreviousReading);
                    Cumulative = Integer.parseInt(CumulativeIndex);
                }


                if (v != arg0) {

                    if (!Caption.getText().toString().equals("")
                            && Cumulative == 1) {

                        int tag = ((Integer) arg0.getTag());
                        CurrentMeterReading = Integer.valueOf(Caption.getText()
                                .toString());


                        //CurrentReading.put("Tag"+ tag, CurrentMeterReading);
                        //if(CurrentReading.containsKey("Tag"+ tag)){
                         //  
                        //  Log.d("Contains","Tag"+ tag );
                        //  CurrentReading.remove("Tag"+ tag);
                        //}
                    //  }else{
                        //  
                             CurrentReading.put("Tag"+ tag,CurrentMeterReading);
                        //}
                        //getReading.add(CurrentReading);
                             Log.d("CurrentReading",CurrentReading.toString() );
                        if (CurrentMeterReading < previousMeterReading) {
                            AlertDialog.Builder builder = new AlertDialog.Builder(
                                    context);
                            builder.setTitle("WARNING");
                            builder.setIcon(android.R.drawable.ic_dialog_alert);
                            builder.setMessage("Current value cannot be less than Previous value for metre");
                            builder.setPositiveButton("ok",
                                    new DialogInterface.OnClickListener() {

                                        public void onClick(
                                                DialogInterface dialog,
                                                int which) {

                                            //Caption.requestFocus();

                                        }
                                    });

                            AlertDialog diag = builder.create();
                            diag.show();

                            // Caption.requestFocus();
                            // v = null;
                            // Caption = null;
                        } 
                    }else {
                            if (Cumulative == 0

                                && !Caption.getText().toString().equals("")) {
                                int tag = ((Integer) arg0.getTag());
                            // int tag1 = ((Integer) arg0.getTag());
                            CurrentMeterReading = Integer.valueOf(Caption
                                    .getText().toString());


                            CurrentReading.put("Tag" +tag, CurrentMeterReading);
                            if(CurrentReading.containsKey("Tag"+ tag)){
                                CurrentReading.put("Tag"+ tag,CurrentMeterReading);
                            }
                            //getReading.add(CurrentReading);
                        }
                        }

                    //Caption.requestFocus();
                    v = null;
                    Caption = null;
                }

            }
        });

        ed_Current.setText(myList.get(position));
        return view;
    }
}

and my xml which im binding with listview using simpleadapter

    <?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:paddingBottom="6dip"
    android:paddingTop="4dip" >

    <TextView
        android:id="@+id/txt_Meter_Name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:width="140dp" />

    <TextView
        android:id="@+id/txt_Previous"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:width="100dp" />

    <EditText
        android:id="@+id/ed_Current"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:imeOptions="actionNext|actionDone"
        android:inputType="number"
        android:numeric="integer"
        android:singleLine="true"
        android:width="100dp" >
    </EditText>

</LinearLayout>

Thanks in advance

  • 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-05-30T09:13:14+00:00Added an answer on May 30, 2026 at 9:13 am

    Go through below link you will get the Idea :

    http://vikaskanani.wordpress.com/2011/07/27/android-focusable-edittext-inside-listview/

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

Sidebar

Related Questions

I have a problem with getting text from EditText field to insert it in
Have problem while getting data from Memcached on .NET MVC solution. I have this
I have a strange problem. I am getting a stream of text from a
I have a problem with getting jquery to retrieve results from a WCF service.
I'm using Stroustrup's swan book. I have run into a problem getting output from
reference from: Merging Variable PHP I have problem with $_POST getting blank null after
I have a problem getting an inputed date (yyyyMMdd) from an HTML form to
hello i have a problem in getting picture from the url contained in the
http://pastebin.com/babqrrqa Like the title says, i have problems with getting the text from a
I have a problem getting the right Price for a product based on Effectivity

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.