0

私のアプリケーションでは、リストビューのタッチイベントのオンクリックで新しいアクティビティを開始しようとするたびに、1 つのタブでタブビュー内にリストを表示しています。webview で新しいアクティビティを開始したいと考えています。

showNewsListView.setAdapter(listAdapter);
 showNewsListView.setOnItemClickListener(new OnItemClickListener(){
  public void onItemClick(AdapterView<?> arg0, View arg1, int position,
        long arg3) {
            Log.v("status ","tab on   position"+position);
           Intent myIntent = new Intent(BizTab.this, MainView.class);
           startActivity(myIntent);

          }
          });

 getUrlData(baseUrl);

 }

これだけのコードを実行するとアプリがクラッシュするので、新しいアクティビティを非同期で開始する必要があるという解決策を見つけるだけなので、今はこれをやっています:

    showNewsListView.setAdapter(listAdapter); 
    showNewsListView.setOnItemClickListener(new OnItemClickListener(){
     public void onItemClick(AdapterView arg0, View arg1, int position, long arg3) { Log.v("status ","tab on position"+position);

         new ShowFullNews().execute();
      }
      });
 getUrlData(baseUrl);

 }`

`showNewsListView.setAdapter(listAdapter);
 showNewsListView.setOnItemClickListener(new OnItemClickListener(){
  public void onItemClick(AdapterView<?> arg0, View arg1, int position,
        long arg3) {
            Log.v("status ","tab on   position"+position);

         new ShowFullNews().execute();
      }
      });
 getUrlData(baseUrl);

 }`

次に、コードがクラッシュし、エラーが発生せず、2 つの警告が表示されます。

onTouch と post execute の両方の場所で新しいアクティビティを開始すると、コードは機能しますが、ここでは最初に画面を表示し、次に自動的にその画面を更新して、見栄えがよくありません。それで回避する方法。私を助けてください。

私の作業コードは次のとおりです。

public void onItemClick(AdapterView<?> arg0, View arg1, int position,
        long arg3) {
            Log.v("status ","tab on   position"+position);

            //set bundle to send data into other activity
            b.putInt("total", 10);
            b.putInt("position",position);
            b.putStringArray("allurls", allsNewsUrls);
            b.putString("returnname", "BizTab");
            b.putString("footertext","Biz");
            b.putInt("tabid", 3);

           Intent myIntent = new Intent(BizTab.this, MainView.class);
            myIntent.putExtras(b);
            startActivity(myIntent);
            new ShowFullNews().execute();
      }
      });

 protected void onPostExecute(Long result) { try { 
   Intent myIntent2 = new Intent(BizTab.this, MainView.class);

 startActivity(myIntent2);


} catch (Exception e) {
 Log.v("error","error in starting new activity");
 e.printStackTrace();
}

  }`

ログが生成され、アプリが自動的に閉じます。

12-07 11:55:18.684: WARN/InputManagerService(72): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@44067388
12-07 11:55:20.792: VERBOSE/status(419): tab on   position0
12-07 11:55:20.814: INFO/ActivityManager(72): Starting activity: Intent { cmp=org.nuvus/.MainView (has extras) }
12-07 11:55:20.872: DEBUG/PhoneWindow(419): couldn't save which view has focus because the focused view com.android.internal.policy.impl.PhoneWindow$DecorView@43ea45d8 has no id.
12-07 11:55:21.023: VERBOSE/status(419): mainView oncreate called
12-07 11:55:21.452: VERBOSE/status(419): onStartcalled
12-07 11:55:21.962: INFO/ActivityManager(72): Displayed activity org.nuvus/.MainView: 1072 ms (total 1072 ms)
12-07 11:55:22.082: INFO/AndroidRuntime(419): AndroidRuntime onExit calling exit(0)
12-07 11:55:22.173: INFO/ActivityManager(72): Process org.nuvus (pid 419) has died.
12-07 11:55:22.183: INFO/WindowManager(72): WIN DEATH: Window{43fe6f30 org.nuvus/org.nuvus.Main paused=true}
12-07 11:55:22.202: INFO/WindowManager(72): WIN DEATH: Window{440f9620 org.nuvus/org.nuvus.MainView paused=false}
12-07 11:55:22.283: INFO/UsageStats(72): Unexpected resume of com.android.launcher while already resumed in org.nuvus
12-07 11:55:22.303: WARN/InputManagerService(72): Got RemoteException sending setActive(false) notification to pid 419 uid 10032

私を助けてください...

4

1 に答える 1

2

それ以外の:

Intent myIntent = new Intent(BizTab.this, MainView.class);
myIntent.putExtras(b);
startActivity(myIntent);

試してみてください:

Intent myIntent = new Intent(getBaseContext(), BizTab.this); <!-- or MainView.class-->
myIntent.putExtras(b);
myIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(myIntent);
于 2010-12-07T14:26:00.110 に答える