Back to project page 101AndroidApps.
The source code is released under:
Licenced under the Creative Commons Attribution 4.0 licence. For full text see http://creativecommons.org/licenses/by/4.0/
If you think the Android project 101AndroidApps listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.hulzenga.ioi.android.app_003; //from w w w. jav a 2 s. c o m import android.content.Context; import android.database.Cursor; import android.view.View; import android.widget.LinearLayout; import android.widget.SimpleCursorAdapter; import com.hulzenga.ioi.android.R; /** * A custom implementation of the SimpleCursorAdapter. This custom adapter * stores the name and id values of monsters in the tag of layout element of * each row */ class MonsterListAdapter extends SimpleCursorAdapter { public MonsterListAdapter(Context context, int layout, Cursor c, String[] from, int[] to, int flags) { super(context, layout, c, from, to, flags); } @Override public void bindView(View view, Context context, Cursor cursor) { super.bindView(view, context, cursor); // add a tag to the LinearLayout of each view containing the id and name // of the element LinearLayout layout = (LinearLayout) view.findViewById(R.id.app_003_linearItemLayout); layout.setTag(R.id.app_003_item_id, cursor.getLong(0)); layout.setTag(R.id.app_003_item_name, cursor.getString(1)); } }