I have a ListView activity, and I want the EditText (and, ultimately, the button with it) to appear above it.
I believe my xml is ok, but for some reason the EditText is not showing. ListView takes up the whole screen :(
This is what my XML looks like:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<EditText
android:id="@+id/newitemtext"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:hint="@string/add_new_item"
android:maxLines="1"
/>
<ListView
android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/android:empty"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/inbox_no_items"
/>
</LinearLayout>
Any ideas?
Note. On the layout tab of the xml file in Eclipse, EditText is displayed. When I run my application in the emulator, it is not.
thank you for your time
Update:
Here I set the content view to my onCreate method
m_aryNewListItems = new ArrayList<MyListItem>();
m_Adapter = new MyListAdapter(this, R.layout.layout_list, m_aryNewListItems);
setListAdapter(m_Adapter);
Here is my advanced ArrayAdapter:
private class MyListAdapter extends ArrayAdapter<MyListItem> {
private ArrayList<MyListItem> m_items;
public MyListAdapter(Context context, int textViewResourceId, ArrayList<MyListItem> items) {
super(context, textViewResourceId, items);
this.m_items = items;
}
public MyListItem getItem(int position) {
if (m_items.size() > position) {
return m_items.get(position);
}
else {
return null;
}
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.layout_list_item, null);
}
MyListItem lstItem = m_items.get(position);
if (lstItem != null) {
TextView txtItem = (TextView) v.findViewById(R.id.list_itemname);
TextView txtQty = (TextView) v.findViewById(R.id.list_itemqty);
TextView txtPlace = (TextView) v.findViewById(R.id.list_place);
if (txtItem != null) {
txtItem.setText(lstItem.getItemName());
}
String strQtyText = "Qty: ";
if (txtQty != null && lstItem.getItemQty() != -1) {
BigDecimal bd = new BigDecimal(lstItem.getItemQty());
strQtyText += bd.stripTrailingZeros().toString();
if(lstItem.getItemQtyUnitId() != -1) {
strQtyText += " " + lstItem.getItemQtyUnitTextAbbrev();
}
}
else {
strQtyText += "--";
}
txtQty.setText(strQtyText);
if (txtPlace != null && lstItem.getPlaceName() != null) {
txtPlace.setText(lstItem.getPlaceName());
}
}
return v;
}
}
source
share