asynctask 중 onPostExecute가 있는데 customDialog를 표시하는 함수를 호출하고 있습니다. AsyncTask에서 사용자 정의 Dialog 호출하기
이
내 AsyncTask를private class DBTask extends AsyncTask<Long, Boolean, Integer>{
ProgressDialog ServerPD = new ProgressDialog(MRRankingActivity.this);
@Override
protected void onPreExecute()
{
ServerPD = ProgressDialog.show (MRRankingActivity.this, "", "Connecting to server...", true, false);
}//End of onPreExecute
@Override
protected Integer doInBackground(Long... params)
{
int isSuccess=0;
publishProgress(isOnline());
if(isOnline())
{
getDBData();
if(isOK)
{
isSuccess=1;
}
}
}
return isSuccess;
}
@Override
protected void onProgressUpdate(Boolean... isConnection) {
// TODO Auto-generated method stub
super.onProgressUpdate(isConnection);
if(isOnline())
{
ServerPD.setMessage("Retreving Data");
}
}
@Override
protected void onPostExecute(Integer result) {
if (ServerPD.isShowing())
{
ServerPD.dismiss();
}
if(result==1)
{
customDialog();
}
}//End of onPostExecute
}//End of DBTask
입니다 그리고 이것은 내 customDialog 기능
public void customDialog(){
Dialog dialog=new Dialog(MRRankingActivity.this);
dialog.requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
dialog.getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.string.app_name);
dialog.setContentView(R.layout.result_dialog);
final ListView ResultView = (ListView) findViewById(R.id.ListResult);
result_Adapter=new ArrayAdapter<String>(MRRankingActivity.this,android.R.layout.simple_list_item_1,result_Array);
//Bind Array Adapter to ListView
ResultView.setAdapter(result_Adapter);
dialog.show();
}//end of custom dialog function
입니다 나는 점점 오전이 코드를 실행할 때이 지금 내 result_dialog.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:orientation="vertical">
<ListView android:id="@+id/ListResult"
android:layout_height="wrap_content"
android:layout_width="fill_parent"/>
</LinearLayout>
</RelativeLayout>
입니다 이 오류
난 내 customDialog 기능에//ResultView.setAdapter(result_Adapter);
을 언급하는 경우
FATAL EXCEPTION: main
java.lang.NullPointerException
at com.lalsoft.mobileranking.MRRankingActivity.customDialog(MRRankingActivity.java)
at com.lalsoft.mobileranking.MRRankingActivity$DBTask.onPostExecute(MRRankingActivity.java) at com.lalsoft.mobileranking.MRRankingActivity$DBTask.onPostExecute(MRRankingActivity.java)
at android.os.AsyncTask.finish(AsyncTask.java)
at android.os.AsyncTask.access$300(AsyncTask.java)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java)
at android.os.Handler.dispatchMessage(Handler.java)
at android.os.Looper.loop(Looper.java)
at android.app.ActivityThread.main(ActivityThread.java)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java)
는 customDialog리스트 뷰없이 표시됩니다. 이 오류는 내가 ListView에 어댑터를 설정할 때 발생합니다.
이 문제를 해결하는 방법 ?? 제발 도와주세요
무슨 일이 ..? –
감사합니다. 그것은 일했습니다 :). 그것은 내가 멍청하다는 것을 확인합니다. 다시 한 번 감사의 친구 – Shijilal
가장 환영합니다 .... –