我想添加ProgressDialog一个适配器。AFAIK,.this用于活动和getActivity.getApplicationContext()片段。那适配器呢?可能吗?
Unable to add window -- token null is not valid; is your activity running?使用时出现错误mContext.getApplicationContext()。
编辑:
在一个片段中,我将卡片显示为
allGroupsView = (RecyclerView) rootView.findViewById(R.id.allGroupsView);
adapterGroup = new AdapterGroup(getActivity().getApplicationContext(), results);
allGroupsView.setAdapter(adapterGroup);
allGroupsView.setLayoutManager(new LinearLayoutManager(getActivity().getApplicationContext()));
Run Code Online (Sandbox Code Playgroud)
在班上 AdapterGroup
public class AdapterGroup extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private Context mContext;
private LayoutInflater inflater;
List<DataGroup> data= Collections.emptyList();
DataGroup current;
public AdapterGroup(Context context, List<DataGroup> results) {
this.mContext = context;
inflater = LayoutInflater.from(mContext);
this.data = results;
}
// Inflate the layout when viewholder created …Run Code Online (Sandbox Code Playgroud)