Back to project page android-listview-custom-view.
The source code is released under:
MIT License
If you think the Android project android-listview-custom-view 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.bignerdranch.android.listitemviewdemo; /*from w w w .j a va 2s . com*/ import android.content.Context; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.TextView; public class ItemView extends RelativeLayout { private TextView mTitleTextView; private TextView mDescriptionTextView; private ImageView mImageView; public static ItemView inflate(ViewGroup parent) { ItemView itemView = (ItemView)LayoutInflater.from(parent.getContext()) .inflate(R.layout.item_view, parent, false); return itemView; } public ItemView(Context c) { this(c, null); } public ItemView(Context context, AttributeSet attrs) { this(context, attrs, 0); } public ItemView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); LayoutInflater.from(context).inflate(R.layout.item_view_children, this, true); setupChildren(); } private void setupChildren() { mTitleTextView = (TextView) findViewById(R.id.item_titleTextView); mDescriptionTextView = (TextView) findViewById(R.id.item_descriptionTextView); mImageView = (ImageView) findViewById(R.id.item_imageView); } public void setItem(Item item) { mTitleTextView.setText(item.getTitle()); mDescriptionTextView.setText(item.getDescription()); // TODO: set up image URL } public ImageView getImageView () { return mImageView; } public TextView getTitleTextView() { return mTitleTextView; } public TextView getDescriptionTextView() { return mDescriptionTextView; } }