MainActivity [A]
public class ViewActivity extends AppCompatActivity implements
FilterDialogFragment.FilterListener,
AffichageAdapter.OnAffichageSelectedListener {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view);
ButterKnife.bind(this);
[B]类:当我单击它在ViewActivity中显示时,我想创建一个AlertDialogue
public class AffichageAdapter extends FirestoreAdapter<AffichageAdapter.ViewHolder> {
AlertDialog.Builder Alert = new AlertDialog.Builder(What i Put here ! );
答案 0 :(得分:1)
YourClassName.this或getContext()
答案 1 :(得分:0)
如果您试图在MainActivity A中显示来自其他类的警报。 您应该将MainActivity的getContext()参数传递给该B类的show alert函数。
答案 2 :(得分:0)
在SELECT *, COUNT(mobile_no) FROM duplicate GROUP BY mobile_no HAVING COUNT(mobile_no) > 1;
类中,您可以这样声明一个字段:
AffichageAdapter
和private Context mContext;
public AffichageAdapter(Context context){
this.mContext = context;//get context by constructor
}
ViewActivity
然后:
AffichageAdapter adapter = new AffichageAdapter(this);//"this" means ViewActivity, its a context.
xxx.setAdapter(adapter); // in some place.