片段 - 标签 - 进度对话框

时间:2013-03-16 21:09:45

标签: android-fragments progressdialog android-tabs

晚上好, 我使用TabsListener实现了一个包含3个选项卡(片段)的应用程序。 当我按下第一个Tab片段上的特定按钮时,我正在尝试显示进度对话框。问题是进度对话框从不显示,其他一切正常。 我对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!!!!!!!!!!!!

0 个答案:

没有答案