晚上好,我使用 TabsListener 实现了一个具有 3 个选项卡(片段)的应用程序。当我按下第一个选项卡片段上的特定按钮时,我试图显示一个进度对话框。问题是进度对话框永远不会出现,其他一切正常。我对android很陌生,我相信答案很简单,但我花了很多时间试图找出解决方案。下面是我的代码
public class AFragment extends DialogFragment {
static TextView tx;
Button bt;
OnClickListener handler1;
OnClickListener handler2;
SQLiteDatabase mydb;
int counter=0;
private Button mStartActivityButton;
public final static String ProgressInsert = "Please wait while data is being inserted...";
public final static String ProgressSelect = "Please wait while your query is being executed ...";
/**/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view;
view=inflater.inflate(R.layout.afragment, container, false);
final ProgressDialog pd = new ProgressDialog(view.getContext());
pd.setCancelable(false);
pd.setMessage("Working...");
pd.isIndeterminate();
//pd.setContentView(view);
pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
tx = (TextView) view.findViewById(R.id.textView2);
bt = (Button) view.findViewById(R.id.button1);
mStartActivityButton = (Button)view.findViewById(R.id.start_file_picker_button);
mStartActivityButton.setOnClickListener(handler2 = new View.OnClickListener() {
public void onClick(View v) {
((MainActivity) getActivity()).Browse_Button(view.getContext());
}
});
bt.setOnClickListener(handler1 = new View.OnClickListener() {/////////This is the button i press and i want the progress dialog to appear!
public void onClick(View v) {
pd.show();
tx.setText(((MainActivity) getActivity()).ShowRecs());
pd.hide();
}
});
return view;
}//////End of onCreateView!!!!!
protected static void settxt(StringBuilder textt)
{
//mFilePathTextView.setText(textt);
tx.setText(textt);
}
}//////////End of Afragment Class!!!!!!!!!!!!