2012-10-17 1 views
1

사용자가 버튼을 클릭 할 때 표시 할 ProgressDialog을 만들었습니다. TabgroupProgressDialog 및 TabGroup

여기 ProgressDialog

final ProgressDialog myPd_ring=ProgressDialog.show(MainActivity.this, "Please wait", "Loading please wait..", true); 
     myPd_ring.setCancelable(false); 
     new Thread(new Runnable() { 
       public void run() { 
        // TODO Auto-generated method stub 
        try 
        { 
         //Some data binding here.... 
        }catch(Exception e){ 

        } 
        myPd_ring.dismiss(); 
        Intent edit = new Intent(getDialogContext(), MerchantActivity.class); 
        TabGroupActivity parentsActivity = (TabGroupActivity)getParent(); 
        parentsActivity.startChildActivity("MerchantActivity", edit); 
       } 
     }).start(); 

에 내 코드 이제 모든 것이 잘 작동 내가 의도를 사용할 때까지입니다 내부 그런데

내 활동이다.

10-17 16:35:21.429: E/AndroidRuntime(11604): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.mobileoptima.perxclub/com.mobileoptima.perxclub.MerchantActivity}: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare() 
10-17 16:35:21.429: E/AndroidRuntime(11604): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1573) 
10-17 16:35:21.429: E/AndroidRuntime(11604): at android.app.ActivityThread.startActivityNow(ActivityThread.java:1491) 
10-17 16:35:21.429: E/AndroidRuntime(11604): at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127) 
10-17 16:35:21.429: E/AndroidRuntime(11604): at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339) 
10-17 16:35:21.429: E/AndroidRuntime(11604): at com.mobileoptima.perxclub.TabGroupActivity.startChildActivity(TabGroupActivity.java:55) 
10-17 16:35:21.429: E/AndroidRuntime(11604): at com.mobileoptima.perxclub.CardsActivity$2.run(CardsActivity.java:318) 
10-17 16:35:21.429: E/AndroidRuntime(11604): at java.lang.Thread.run(Thread.java:1019) 
10-17 16:35:21.429: E/AndroidRuntime(11604): Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare() 

10-17 16:35:21.429: E/AndroidRuntime(11604): at android.os.Handler.<init>(Handler.java:121) 
10-17 16:35:21.429: E/AndroidRuntime(11604): at android.app.Activity.<init>(Activity.java:680) 
10-17 16:35:21.429: E/AndroidRuntime(11604): at com.mobileoptima.perxclub.MerchantActivity.<init>(MerchantActivity.java:63) 
10-17 16:35:21.429: E/AndroidRuntime(11604): at java.lang.Class.newInstanceImpl(Native Method) 
10-17 16:35:21.429: E/AndroidRuntime(11604): at java.lang.Class.newInstance(Class.java:1409) 
10-17 16:35:21.429: E/AndroidRuntime(11604): at android.app.Instrumentation.newActivity(Instrumentation.java:1021) 
10-17 16:35:21.429: E/AndroidRuntime(11604): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1565) 
10-17 16:35:21.429: E/AndroidRuntime(11604): 
... 6 more 

왜 내가 그 오류가 있습니까 : 나는 오류 여기

내 로그 캣입니다 무엇입니까? 내가 염려하는 한 나는 부모를 부른다. 도와주세요??

답변

1

기본 UI 스레드에서 parentsActivity.startChildActivity("MerchantActivity", edit);을 실행 해보십시오. 이런 식으로 뭔가가 :

runOnUiThread(new Runnable() { 
    public void run() { 
     parentsActivity.startChildActivity("MerchantActivity", edit); 
    } 
}); 

BTW, 당신은 이것에 대한 finalTabGroupActivity parentsActivityIntent edit를 선언해야합니다.

0

귀찮아, 내가 찾고있는 대답을 찾았습니다. 방금 ​​추가하면 매력처럼 작동합니다.

   runOnUiThread(new Runnable() { 
           public void run() { 
           // Toast.makeText(activity, "Hello", Toast.LENGTH_SHORT).show(); 
           Intent edit = new Intent(getParent(), MerchantActivity.class); 
           TabGroupActivity parentsActivity = (TabGroupActivity)getParent(); 
           parentsActivity.startChildActivity("MerchantActivity", edit); 
           } 
          });