Android : Listview with edittext issue when appear keybord

on Friday, August 22, 2014


enter image description here


i am using custom listview with edit text


when i click on last edit text of listview and all full activity is scroll to up


but i want to scroll only listview when keyboard appear


enter image description here


my java code of custom listview



class CreateAdapter extends ArrayAdapter<String> {
String[] strItecode=null;
String[] strItem;
String[] strQuantity;
Context context;

int temp;
CreateAdapter(Context context, String[] strItemcode, String[] strItem,
String[] strQauntity) {
super(context, R.layout.create_list_item, R.id.txtItemcode, strItemcode);
this.context = context;
this.strItecode = strItemcode;
this.strItem = strItem;
this.strQuantity = strQauntity;
// text= new String[strItem.length];
}
private int editingPosition = 0;
private TextWatcher watcher = new TextWatcher() {
public void onTextChanged(CharSequence s, int start, int before, int count) {
text[editingPosition] = s.toString();
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) { }
public void afterTextChanged(Editable s) { }
};

public View getView( final int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
temp=position;
LayoutInflater mInflater = (LayoutInflater) context
.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {

holder = new ViewHolder();
convertView = mInflater
.inflate(R.layout.create_list_item, parent, false);

holder.txtItecode = (TextView) convertView
.findViewById(R.id.txtItemcode);
holder.txtItem = (TextView) convertView
.findViewById(R.id.txtItem);
holder.editQuantity = (EditText) convertView
.findViewById(R.id.editcreateQuantity);
holder.editQuantity.setTag(position);

convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.editQuantity.removeTextChangedListener(watcher);
if(text[temp].contentEquals("0"))
holder.editQuantity.setText("");
else
holder.editQuantity.setText(text[temp]);

holder.editQuantity.setOnFocusChangeListener(new OnFocusChangeListener() {
public void onFocusChange(View v, boolean hasFocus) {
if(hasFocus) editingPosition = position;
}
});

holder.editQuantity.addTextChangedListener(watcher);

// The rest is good, just make sure to remove the call to setting the EditText's text at the end
holder.txtItecode.setText(strItecode[position]);
holder.txtItem.setText(strItem[position]);
// holder.editQuantity.setText(text[temp]);
return convertView;


}

class ViewHolder {
TextView txtItecode;
TextView txtItem;
EditText editQuantity;
}
}


My manifest code of this activity



<activity android:name=".CreateChallan" android:label="@string/app_name"
android:screenOrientation="portrait"

android:windowSoftInputMode="adjustPan" />


Please Help me how i can set scroll only listview not full activity when keyboard appear


Thanks In Advance


And i am realy sorry about my bad english


0 comments:

Post a Comment