I am writing XML in following way, list_item2 contains TextView and EditText, while list_item is another XML contains only TextView,
<?xml version="1.0" encoding="utf-8"?>
<TextView android:id="@+id/textItem"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
android:textSize="16sp" >
</TextView>
<EditText
android:id="@+id/editText1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</EditText>
I am using the xml in ListView, such as
public View getView(int position, View convertView, ViewGroup parent) {
View row;
if(position!=2) {
LayoutInflater inflater = getLayoutInflater();
row = inflater.inflate(R.layout.list_item, parent, false);
}
else {
LayoutInflater inflater = getLayoutInflater();
row = inflater.inflate(R.layout.list_item2, parent, false);
}
TextView tv = (TextView) row.findViewById(R.id.textItem);
tv.setText(getItem(position));
tv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
}
});
but It is creating output like
TextView
EditText
I want both on same row, such as
TextView EditText
Any one edit the XML and let me know the hierarchy for creating GUI in Android Apps
Take your
EditTextandTextViewinside aLinearLayouthaving horizontal orientation (which is applied by default) and setlayout_weight = 1or whatever do you want toEditTextandTextView