我在我的适配器类中单击时需要一些帮助。
这是我想在单击项目时运行的代码。 connectOrDisconnectUser()
private void connectOrDisconnectUser(final int position) {
final AlertDialog.Builder builder = new AlertDialog.Builder(
RelationshipRemoved.this);
builder.setMessage("Do you want to un tag " + usersInfo.get(position).get(
RelationshipRemoved.likedOne))
.setCancelable(false)
.setPositiveButton("Yes",
new DialogInterface.OnClickListener() {
//do something
public void onClick(DialogInterface dialog, int randomvar) {
Log.d("OkHttpRemove", "getting removing!");
String username = (globalInt);
String UT = usersInfo.get(position).get(
RelationshipRemoved.likedOne);
String type = "remove";
BackgroundWorker backgroundWorker = new BackgroundWorker(getApplicationContext());
backgroundWorker.execute(type, username, UT);
startActivity(new Intent(RelationshipRemoved.this, MainActivity.class));
Toast.makeText(context, "UnTagged!",
Toast.LENGTH_SHORT).show();
}
})
.setNegativeButton("No",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
dialog.cancel();
}
});
final AlertDialog alert = builder.create();
alert.show();
}
保存适配器的文件称为AdapterClass,使用适配器类的类称为RelationshipRemoved。当我尝试编写此代码时。我在此行RelationshipRemoved.this
,RelationshipRemoved.this);
和startActivity
上RelationshipRemoved.this
startActivity(new Intent(RelationshipRemoved.this, MainActivity.class));
收到错误bar
出了什么问题?