gpt4 book ai didi

java - 我想在一项 Activity 中显示两个自定义对话

转载 作者:太空宇宙 更新时间:2023-11-04 10:21:18 25 4
gpt4 key购买 nike

如何在一个 Activity 中显示两个自定义对话。当我单击一个请求培训时,它必须导航到 Gmail,并且程序必须导航到自定义列表页面。请参见下图。

enter image description here

public void showProcedureDialog (final ArrayList)过程列表){

  final Dialog dialog = new Dialog(activity);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.procedure_dialog_layout);
dialog.setCanceledOnTouchOutside(true);

procedureListView = (ListView) dialog.findViewById(R.id.procedureList);
procedureListView.setAdapter(new ProcedureAdapter(procedurelist));
procedureListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {


String selectedurl =procedurelist.get(position).getURL();

Bundle bundle = new Bundle();
bundle.putString("url",selectedurl);
Intent intent = new Intent(getApplicationContext(),ProcedureActivity.class);
intent.putExtras(bundle);
startActivity(intent);

if(dialog!=null){
dialog.dismiss();
}

}
});

dialog.show();

public void showRequestTrainingDialog(final ArrayList procedurelist){

  final Dialog dialog = new Dialog(activity);
dialog.setContentView(R.layout.training_dialog_layout);
dialog.setCanceledOnTouchOutside(true);


Bundle bundle = new Bundle();
bundle.putString("url","https://info.orendatech.com/orenda-training");
Intent intent = new Intent(getApplicationContext(), RequestTrainingActivity.class);
intent.putExtras(bundle);
startActivity(intent);

if (dialog!=null){
dialog.dismiss();
}
dialog.show();

公共(public)类ProcedureAdapter扩展BaseAdapter{

  private ArrayList<ProcedureRootDto> procedurelist;
private LayoutInflater inflater;
private TextView procedurename;

public ProcedureAdapter(ArrayList<ProcedureRootDto> procedurelist){
this.procedurelist = procedurelist;
inflater = LayoutInflater.from(activity);
}

@Override
public int getCount() {
return (procedurelist == null) ? 0 : procedurelist.size();
}


@Override
public Object getItem(int position) {
return procedurelist.get(position);
}

@Override
public long getItemId(int position) {
return position;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {

if(convertView==null){
convertView = inflater.inflate(R.layout.procedure_item_layout,parent,false);
}

procedurename = (TextView) convertView.findViewById(R.id.procedurename);
procedurename.setText(procedurelist.get(position).getName());

return convertView;
}

程序运行良好,但单击请求培训也会导航到程序链接

最佳答案

试试这个,

已编辑:

final Dialog dialog = new Dialog(activity);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.procedure_dialog_layout);
dialog.setCanceledOnTouchOutside(true);

procedureListView = (ListView) dialog.findViewById(R.id.procedureList);
procedureListView.setAdapter(new ProcedureAdapter(procedurelist));
procedureListView.setOnItemClickListener(new AdapterView.OnItemClickListener()
{
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long
id) {


String selectedurl =procedurelist.get(position).getURL();

if(positon==1){ /// for procedure click

Bundle bundle = new Bundle();
bundle.putString("url",selectedurl);
Intent intent = new
Intent(getApplicationContext(),ProcedureActivity.class);
intent.putExtras(bundle);
startActivity(intent);
}else{ //// for other click

Bundle bundle = new Bundle();
bundle.putString("url","https://info.orendatech.com/orenda-
training");
Intent intent = new Intent(getApplicationContext(),
RequestTrainingActivity.class);
intent.putExtras(bundle);
startActivity(intent);
}

if(dialog!=null){
dialog.dismiss();
}

}
});

dialog.show();

关于java - 我想在一项 Activity 中显示两个自定义对话,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51134696/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com