Back to project page android-custom-views-sample.
The source code is released under:
Apache License
If you think the Android project android-custom-views-sample 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 net.danlew.customviews.view; /* w w w . j ava 2s. com*/ import android.content.Context; import android.view.Gravity; import android.view.LayoutInflater; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import net.danlew.customviews.R; import net.danlew.customviews.data.User; /** * UserView that has a special knowledge of how to bind relevant data. */ public class UserViewEncapsulated extends LinearLayout { private ImageView mIconView; private TextView mNameView; public UserViewEncapsulated(Context context) { super(context); setOrientation(LinearLayout.VERTICAL); setGravity(Gravity.CENTER); LayoutInflater.from(context).inflate(R.layout.user_view_merge, this); mIconView = (ImageView) findViewById(R.id.icon); mNameView = (TextView) findViewById(R.id.name); } public void bind(User user) { mIconView.setImageResource(user.getIcon()); mNameView.setText(user.getName()); } }