Hi,
what i got is 2 listviews which are both subclasses of ListActivity.
One is a simple list with a textview in every row.
The other has some elements in the top, and a list below.
The first and simple row, has its row defnied programmaticly and
selected rows are highlighted.
In the other list i used an XML layout to define the rows layout and
used an inflater to inflate the xml layout. Here, there is noch
highlight on the row when selected, but is should be highlighted.
Maybe anyone has an idea, where to search. Code is below.
Regards,
Daniel
List with highlight working:
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
TripListRowView sv;
if (convertView == null) {
sv = new TripListRowView(this.context, this.trips.elementAt
(position));
} else {
sv = (TripListRowView) convertView;
sv.setTripId(this.trips.elementAt(position).getTripID());
}
return sv;
}
class TripListRowView extends LinearLayout {
TextView tripId = null;
public TripListRowView(Context context, Trip trip) {
super(context);
this.setOrientation(HORIZONTAL);
this.setPadding(0, 5, 0, 5);
tripId = new TextView(context);
tripId.setText("Trip: " + trip.getTripID());
tripId.setTextSize(25.0f);
tripId.setTextColor(Color.BLACK);
tripId.setPadding(10, 0, 0, 0);
addView(tripId, new LinearLayout.LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
}
void setTripId(String tripId) {
this.tripId.setText(tripId);
}
}
Not working list:
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.tripdetail);
....
}
the xmlfile for the screen:
<?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="fill_parent" android:background="#FFFFFF"
android:orientation="vertical">
<TableLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:id="@+id/tableLay" android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10sp">
<TableRow android:minHeight="50px">
<TextView android:text="@string/tripdetail_tripID"
android:paddingRight="20px"
android:layout_gravity="center_vertical" android:textColor="#000000"/>
<EditText android:id="@+id/tripnumber"
android:layout_height="wrap_content"
android:background="@android:drawable/editbox_background"
android:layout_width="200sp" android:lines="1"
android:maxLength="15"
android:inputType="text"
android:layout_gravity="center_vertical"
android:focusable="false"/>
</TableRow>
<TableRow android:minHeight="50px">
<TextView android:text="@string/tripdetail_start"
android:paddingRight="20px"
android:layout_gravity="center_vertical" android:textColor="#000000"/>
<EditText android:id="@+id/start"
android:layout_height="wrap_content"
android:background="@android:drawable/editbox_background"
android:layout_width="200sp" android:lines="1"
android:maxLength="15"
android:inputType="text"
android:layout_gravity="center_vertical"
android:focusable="false"/>
</TableRow>
<TableRow android:minHeight="50px">
<TextView android:text="@string/tripdetail_end"
android:paddingRight="20px"
android:layout_gravity="center_vertical" android:textColor="#000000"/>
<EditText android:id="@+id/end"
android:layout_height="wrap_content"
android:background="@android:drawable/editbox_background"
android:lines="1" android:maxLength="15"
android:inputType="text"
android:layout_gravity="center_vertical"
android:layout_width="wrap_content" android:focusable="false"/>
</TableRow>
</TableLayout>
<ImageView android:id="@+id/ImageView01"
android:layout_height="wrap_content" android:src="@drawable/
devider_long" android:layout_width="fill_parent"/>
<ListView android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:drawSelectorOnTop="false" android:divider="@drawable/
listdevider" android:headerDividersEnabled="true"
android:clickable="true">
</ListView>
</LinearLayout>
the xml file for the row:
<?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="fill_parent"
android:background="#FFFFFF" android:orientation="vertical">
<TextView android:text="Test" android:id="@+id/firstText"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textColor="#000000"
android:cursorVisible="true" android:clickable="true"></TextView>
<TextView android:text="check2" android:id="@+id/secondText"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textColor="#000000"></
TextView>
<TextView android:text="check2" android:id="@+id/thirdText"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textColor="#000000"></
TextView>
<TextView android:text="check2" android:id="@+id/fourthText"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textColor="#000000"></
TextView>
</LinearLayout>
And the list adapter:
public View getView(int position, View convertView, ViewGroup parent)
{
LayoutInflater inflater =
(LayoutInflater)context.getSystemService
(Context.LAYOUT_INFLATER_SERVICE);
View ret = inflater.inflate(R.layout.tripdetailrow, null);
return ret;
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---