小编mba*_*r14的帖子

如何在警报对话框中添加两个编辑文本字段

我正在尝试使用警告对话框来提示在android中输入用户名和密码.我在这里找到了这段代码:

  if (token.equals("Not Found"))
    {
        LayoutInflater factory = LayoutInflater.from(this);            
        final View textEntryView = factory.inflate(R.layout.userpasslayout, null);

        AlertDialog.Builder alert = new AlertDialog.Builder(this); 

        alert.setTitle("Please Login to Fogbugz"); 
        alert.setMessage("Enter your email and password"); 
        // Set an EditText view to get user input  
        alert.setView(textEntryView); 
        AlertDialog loginPrompt = alert.create();

        final EditText input1 = (EditText) loginPrompt.findViewById(R.id.username);
        final EditText input2 = (EditText) loginPrompt.findViewById(R.id.password);

        alert.setPositiveButton("Login", new DialogInterface.OnClickListener() { 
        public void onClick(DialogInterface dialog, int whichButton) { 
            input1.getText().toString(); **THIS CRASHES THE APPLICATION**


        } 
        }); 

        alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { …
Run Code Online (Sandbox Code Playgroud)

android dialog login

54
推荐指数
5
解决办法
11万
查看次数

如何使用单独的线程来执行http请求

我有一个应用程序在用户单击某些按钮时执行HTTP请求(特别是调用FogBugz API).现在,我只是在应用程序启动时创建服务,然后在该服务中调用不同的方法来完成请求.但是,当我这样做时,UI线程中通常会挂起.我看过AsyncTask,但我不确定它会做我想要完成的事情.因为我需要立即解析HTTP请求返回的XML,所以我需要有一个能够将此数据返回给UI线程的进程.ASyncTask能否实现这一目标,还是有其他方式?

    public static InputStream makeRequest(String httpRequest)
    {
        In a separate thread, run HTTP Request, get back and process, return inputstream
    }
Run Code Online (Sandbox Code Playgroud)

其他几个人调用此方法来执行HttpRequests.返回输入流后,其他方法将解析特定信息.

android http android-asynctask

23
推荐指数
2
解决办法
5万
查看次数

标签 统计

android ×2

android-asynctask ×1

dialog ×1

http ×1

login ×1