tabhost组活动不起作用(不建议使用)

时间:2013-03-27 09:18:58

标签: android android-tabhost

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();

}

错误是: android.view.WindowManager $ BadTokenException:无法添加窗口 - 令牌android.app.LocalActivityManager $ LocalActivityRecord@40e16110无效;你的活动在运行吗?

问题

我通过另一个tabhost调用活动。它只加载视图.Web服务和按钮不起作用。当我点击上面显示的按钮时出错。帮我继续下去..

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

否则不推荐使用ActivityGroup ..,我现在应该使用什么..

1 个答案:

答案 0 :(得分:0)

对于您发布的内容,您似乎根本不需要使用ActivityGroup。只需从Feedback课程延长Activity即可。例如:

public class Feedback extends Activity