public void onClick(View v) {
   //referenceOfActivity
  // here is the context, don't know how to use it to get ActionBar title
  Toast.makeText(referenceOfActivity,"Already Liked",Toast.LENGTH_SHORT).show();
}


我想在适配器类中获取操作栏的标题。如您所见,我有活动上下文。

最佳答案

将活动名称强制转换为上下文。
例;

((MainActivity) referenceOfActivity).getSupportActionBar().getTitle()

10-05 19:51