如何在baseadapter中启动新活动我以默认方式打开活动,但不能与baseadapter一起使用
Intent intent = new Intent(context,AnotherActivity.class); context.startActivity(intent);
@Override
public View getView(final int p, View convertView, ViewGroup parent) {
View grid;
LayoutInflater inflater = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
grid = new View(mContext);
grid = inflater.inflate(R.layout.gridview_custom_layout, null);
} else {
grid = (View) convertView;
}
TextView textView = (TextView) grid.findViewById(R.id.gridview_text);
ImageView imageView = (ImageView)grid.findViewById(R.id.gridview_image);
textView.setText(string[p]);
imageView.setImageResource(Imageid[p]);
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
switch (p){
case 0:
Toast.makeText(v.getContext(), "Clicked Laugh Vote", Toast.LENGTH_SHORT).show();
break;
case 1:
Toast.makeText(v.getContext(), "2", Toast.LENGTH_SHORT).show();
break;
case 2:
break;
default:
// Do something else
break;
}
}
});
答案 0 :(得分:0)
Intent yourIntent = new Intent(mContext,Wukong.class);
yourIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
mContext.startActivity(yourIntent);
答案 1 :(得分:0)
您可以使用以下代码来启动新的Activity BaseAdapter:
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mContext.startActivity(new Intent(mContext,YourActivity.class))
}
});