我需要一些进度对话框的帮助。
我正在尝试做的是在读取文件时使用进度对话框样式微调器,当它完成时我希望对话框关闭。
截至目前,它仅在因循环而找到文件后加载。我不知道如何在循环开始之前加载它
public void readFile() {
pb.setMessage("Looking... after, view the tips in the menu bar :) ");
pb.setProgressStyle(ProgressDialog.STYLE_SPINNER);
pb.setIndeterminate(true);
pb.show();
BufferedReader reader = null;
try {
reader = new BufferedReader(
new InputStreamReader(getAssets().open(("account.txt"))));
// do reading, usually loop until end of file reading
String mLine = reader.readLine();// reading each line.
System.out.println("starting to read line in buffer");
while (mLine != null) {
//process line
btn1.setEnabled(false);
if (mLine.toLowerCase().equals(theiraccount)) { // when an account is found stop reading
checking =theiraccount; //trying to set vale of checking to theiraccount
Log.d("if statement in mline",checking);
reader.close();
pb.dismiss();
System.out.println("closed reader");
mLine=null;// trying to stop the loop
btn1.setEnabled(true);
}//end if
else {
}
mLine = reader.readLine();
System.out.println("cheking mLine"+ mLine);
}
} catch (IOException e) {
//log the exception
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
//log the exception
Log.d("Catch buffer","i failed the catch in finally for reading lines");
}
}
}//end buffer reader
if (checking == theiraccount) {
Toast.makeText(this,"im there",Toast.LENGTH_LONG).show();
System.out.println("i just checked if its there");//another test
btn1.setEnabled(true);
tv1.setText("We found your account, click the menu for tips");
pb.dismiss();
} else {
Toast.makeText(this,"im not there",Toast.LENGTH_LONG).show();
btn1.setEnabled(true);
tv1.setText("We cant find your account, sorry dude");
pb.dismiss();
}
}