2013-03-27 82 views
0
public class Feedback extends ActivityGroup { 
protected static LocalActivityManager mLocalActivityManager; 

private EditText fd=null; 
private Button send=null; 
public int res_flag=0; 
public String result=""; 
public String url=""; 
private RelativeLayout newaccount; 
private TextView needhelp=null; 
private String currentDateandTime=""; 
private boolean isonline; 

protected String fd_text=""; 

public void replaceContentView(String id, Intent newIntent) { 
    View view = getLocalActivityManager().startActivity(id,newIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)) .getDecorView(); this.setContentView(view); 
    } 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    // TODO Auto-generated method stub 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.feedback); 
    initialization(); 

    try{ 
     SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); 
     currentDateandTime = sdf.format(new Date()); 
    }catch (Exception e) { 
     System.out.println(e); 
    } 

    send.setOnClickListener(new View.OnClickListener() { 

     @Override 
     public void onClick(View v) { 
     new Feedback.Retrieve().execute(); 

    } 

    }); 


} 

private void initialization() 
{ 
    fd=(EditText)findViewById(R.id.fd); 
    send=(Button)findViewById(R.id.send); 

} 



class Retrieve extends AsyncTask<Void, Integer, Integer> { 

    ProgressDialog pd = null; 


    @Override 
    protected void onPreExecute() { 
     // TODO Auto-generated method stub 
     super.onPreExecute(); 
     pd = new ProgressDialog(Feedback.this); 
     pd.setMessage("Please wait while sending feedback.."); 
     pd.setCancelable(false); 
     pd.show(); 

    } 

    @Override 
    protected Integer doInBackground(Void... params) { 


     try{  
      System.out.println("IN BKGRND"); 

      StrictMode.ThreadPolicy policy1 = new StrictMode.ThreadPolicy.Builder().permitAll().build(); 
      StrictMode.setThreadPolicy(policy1); 



      url="url"+fd_text.toString().trim()+"&datetime="+currentDateandTime; 
      url=url.replace(" ","%20"); 
      url=url.replace("+","%2B"); 

      System.out.println(url); 

     JSONObject json = JSONfunctions.getJSONfromURL(url); 
      JSONObject response1=json.getJSONObject("response"); 
      result=response1.getString("Success").toString().trim(); 
      System.out.println(result); 
     if(result.equalsIgnoreCase("1")) 
     { 
      System.out.println("Logged In"); 

      res_flag=1; 


     } 
     else 
     { 
      System.out.println("failed"); 
      res_flag=5; 
     } 
      } 
       catch (JSONException e) { 
        System.out.println(e); 
       }catch (Exception e) { 
        System.out.println(e); 
       }  
     return null; 

    } 

    @Override 
    protected void onPostExecute(Integer result) { 
     super.onPostExecute(result); 
     pd.dismiss(); 

}tabhost groupactivity不工作(不建議使用)

錯誤是: android.view.WindowManager $ BadTokenException:無法添加窗口 - 令牌[email protected]無效;你的活動正在運行?

問題

我通過另一個tabhost調用活動,它僅加載.The互聯網服務和按鈕不工作的視圖中,當我點擊按鈕,這表明上述error.Help我繼續傢伙。 。

參考: http://www.gamma-point.com/content/android-how-have-multiple-activities-under-single-tab-tabactivity

現在的ActivityGroup已經過時..,我現在應該使用什麼樣的..

回答

0

對於你發佈的內容,似乎並不需要使用ActivityGroup。只需從Activity類擴展您的Feedback即可。例如:

public class Feedback extends Activity 
+0

我在另一個類文件的TabActivity ..當我點擊一個網頁不應該來了,是我編寫GroupActivity..Reference HTTP的tabhost..For出來://www.gamma -point.com/content/android-how-have-multiple-activities-under-single-tab-tabactivity – Coder 2013-03-27 09:32:21

+0

就像我說的,你發佈的代碼並不需要使用ActivityGroup。用Activity替換它看看它是如何去的。 – waqaslam 2013-03-27 09:51:51

+0

View view = getLocalActivityManager()。startActivity(id,newIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView(); this.setContentView(視圖); 雖然我改變太活動上述行不接受getLocalActivityManager().. – Coder 2013-03-27 11:25:45