0
我有一個由四個imageViews組成的自定義首選項。我想在點擊4個imageViews中的第4個時開始一個活動。開始活動自定義首選項android
public class ImagePreference4Locks extends Preference {
public ImagePreference4Locks(final Context context, final AttributeSet attrs,
final int defStyle) {
super(context, attrs, defStyle);
this.setLayoutResource(R.layout.imagepref4locks);
}
@Override
protected void onBindView(View view) {final Context m = this.getContext();
super.onBindView(view);
final ImageView thumb_1 = (ImageView) view.findViewById(R.id.thumb_1);
final ImageView thumb_2 = (ImageView) view.findViewById(R.id.thumb_2);
final ImageView thumb_3 = (ImageView) view.findViewById(R.id.thumb_3);
final ImageView thumb_4 = (ImageView) view.findViewById(R.id.thumb_4);
.........
if (thumb_4 != null) {
thumb_4.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
/////////////////////////////////////////////
Start Activity here:
}}
我怎樣才能從這裏開始的活動,因爲我無法獲得上下文.......
使用這個難道不工作:
Intent cc=new Intent(this.getContext(),HomeActivity.class);
this.getContext().startActivity(cc);