这是来自MySimpleCursorAdapter.java类,而finish()和ovverridePendingTransition()有一个无法解析的错误方法。如何解决这个问题?
@Override
public void bindView(View view, final Context context, final Cursor cursor)
{
//create database
dbhandler = new MyDBAdapter(context);
super.bindView(view, context, cursor);
GridLayout parentView = (GridLayout) view.findViewById(R.id.parentView);
Button button = (Button) view.findViewById(R.id.delete_btn);
button.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View view)
{
// Use interface to send a callback to the activity
Intent myIntent = new Intent(context, SetActActivity.class);
myIntent.putExtra("goalid", cursor.getString(1));
//deleteAlarm(Integer.parseInt(cursor.getString(0)));
dbhandler.deleteActivity(cursor.getInt(1), cursor.getInt(0));
dbhandler.deleteTasks(cursor.getInt(1), cursor.getInt(0));
dbhandler.deleteActivityinTag(cursor.getInt(1), cursor.getInt(0));
overridePendingTransition(0, 0);
myIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
finish();
overridePendingTransition(0, 0);
context.startActivity(myIntent);
Toast.makeText(context, "Button clicked", Toast.LENGTH_SHORT).show();
}
});
我不知道如何解决这个问题。
答案 0 :(得分:1)
尝试一下...
((Activity)mContext).finish();
答案 1 :(得分:-1)
finish()方法适用于activity / context。
试试这个,
context.finish();
和
context. overridePendingTransition(0, 0);
答案 2 :(得分:-1)
如果不从活动类调用finish(),则会出现“无法解析方法”错误。您必须在要调用finish()的类中添加一个函数,并在该类中调用该函数。此功能将解决问题;
private void finishF() {
Activity activity = (Activity)getContext();
activity.finish();
}
您可以调用finishF(),以激活finish()方法。