check EditText value onto ListView android

i am using ListView in main activity and class adapter extends ArrayAdapter with login form only one row.

code adapter like this"

public class AdapterLogin extends ArrayAdapter<ListArrayItem> {

Context mContext;
int layoutResourceId;
ListArrayItem data[] = null;
  public AdapterLogin(Context mContext, int layoutResourceId, ListArrayItem[] data) {

    super(mContext, layoutResourceId, data);

    this.layoutResourceId = layoutResourceId;
    this.mContext = mContext;
    this.data = data;
}
   public View getView(final int position, View convertView, ViewGroup parent) {

    if(convertView==null){

        LayoutInflater inflater = ((Activity) mContext).getLayoutInflater();
        convertView = inflater.inflate(layoutResourceId, parent, false);
    }
//here i have for login like this
  lin_form = new LinearLayout(mContext);
  EditText email_input = new EditText(mContext);  
  Button  btn_sign = new Button(mContext);
  btn_sign.setOnClickListener(login_btn_clicked);
  TextView login_status_message = new TextView(mContext);  
  lin_form.addView(email_input);
  lin_form.addView(btn_sign);
  lin_form.addView(login_status_message); 
  rowitem = (RelativeLayout)convertView.findViewById(R.id.rowitem);
  rowitem.addView(lin_form); 
  return convertView;

}


 public OnClickListener login_btn_clicked = new OnClickListener() {
 String email_value = email_input.getText().toString();
  // i want to see email_value but doesnt show me any thing
  login_status_message.setText("email value:"+ email_value);

};

in main activity i have a code like this:

    FillFooter fillfooter= new FillFooter();
    fillfooter.setFooter(MainActivity.this,"mainactivity");
    fillfooter.fillFooter();

 public static void gotoLogin(Context context){
        Activity activity = (Activity)context;
        activity.setTitle("Broonza: Вход"); 
        list = new HashMap<String, String>();
        listarraymain[0] = new ListArrayItem(1, list);
        AdapterLogin adapter = new AdapterLogin(context, R.layout.row_item, listarraymain);
        listviewtmain.clearFocus();
        listviewtmain.setAdapter(adapter);
 }

in the class fill footer

     public class FillFooter {
     public void setFooter(Context context,String typeactivity){
     this.context = context;    
     this.activity = (Activity) context;
     linaccount = new LinearLayout(context);
     linaccount.setOnClickListener(gotologin);
    }

    public OnClickListener gotologin= new OnClickListener() {

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        MainActivity.gotoLogin(context);

    }
};

} row_item.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="1dp" 
android:paddingBottom="0dp"
android:paddingTop="10dp"
android:id="@+id/rowitem" >

load form login with all fields from adapter to listview work fine, but when clicking button login if email field content text doesn't show that text. The problem is not in the printed error!, The problem in the printing field email value! OnCLickListener() doesnt work. it will work only if i will add text for email_field onto inside adapter like this! email_input.setText("example@mail.ru")

Answers


I think that instead of

if(error !=""){
   login_status_message.setText(error);
  }

should be this:

if(!error.equals(""){
  login_status_message.setText(error);
}

This is basically a string comparsion. If you want to compare a string to a string, you should use equals() instead of !=.


Your problem is that the error value is always null and you can not see the value of email, it is not calling login_status_message.setText("email value:"+ email_value); Change this

 btn_sign.setOnClickListener(login_btn_clicked);
 TextView login_status_message = new TextView(mContext);

by this:

 TextView login_status_message = new TextView(mContext);
 btn_sign.setOnClickListener(login_btn_clicked);

Your is initializing under the getView method and is local to that block; How you are accessing this field outside the method? You have created the object local with the method as-

   EditText email_input = new EditText(mContext); 
   TextView login_status_message = new TextView(mContext);  

inside the getView method. You need to put your Listener inside the getView method as

    btn_sign.setOnClickListener(new OnClickListener() {
    String email_value = email_input.getText().toString();
    // i want to see email_value but doesnt show me any thing
    login_status_message.setText("email value:"+ email_value);
    });

Re-examine the code if you are having another duplicate fields for that.


Thank you for all). after restart eclipse, it work fine.


Need Your Help

Retrieve Hibernate Search results directly from Lucene Index

hibernate lucene full-text-search hibernate-search

How can I execute a search using Hibernate Search that will NOT retrieve the actual entities from the database and will instead just return the Document cache records for these entities? I am makin...

ImportError: No module named goose

python virtualenv pycharm goose

Im trying to work with Python-Goose extractor. I Installed virtualenv, and followed the setup instructions. When running from PyCharm everything works great.