从价值观和textviews比较JSONArray [英] Comparing values from textviews and JSONArray

查看:164
本文介绍了从价值观和textviews比较JSONArray的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很抱歉的(貌似)懒惰的问题,但我一直在寻找,没有运气的解决方案(换句话说,我还没有找到一个解决方案,我明白了)。

我希望让用户通过输入用户名和密码的方式登录到一个应用程序,该用户名和密码必须匹配,从我已经从phpmyadmin的数据库中检索到jsonarray用户名和密码。的用户名和密码都必须在同一行中

下面是我用它来找回我的jsonarray功能:

 私人无效的getData(){JSONArray json的;
尝试{
    。用户= editText1.getText()的toString();
    。密码= editText2.getText()的toString();    JSON = readJsonFromUrl(HTTP://localhost/indextest.php功能=的getData);       视频下载(1000);
  }赶上(例外五){
    Log.e(BACKGROUND_PROC,e.getMessage());
  }

}

我只需要知道如何搜索jsonarray因我从我的textviews检索值。

如果可能,我想找回我可以轻松地分配到一个值,如果像这样的语句:

 公共无效的onClick(视图v){        开关(v.getId()){
            案例R.id.button1:                如果(editText1 =空&放大器;!&放大器;!editText1.length()= 0&放大器;&放大器; editText2 =空&放大器;!&放大器;!editText2.length()= 0){
                    的getData();
                    m_ProgressDialog = ProgressDialog.show(HomeScreen.this,
                              请稍候...,检查详细信息...,真正的);
                        m_ProgressDialog.setCancelable(真);                      如果(/ *的用户名和密码匹配* /){
                      意图I =新意图(这一点,Afterlog.class);
                      startActivity(ⅰ);
                      }                    其他{
                        Toast.makeText(HomeScreen.this的用户名和密码不匹配任何在我们的数据库中...,Toast.LENGTH_SHORT).show();
                    }
                }
                其他{
                    Toast.makeText(HomeScreen.this,请输入用户名和密码......,Toast.LENGTH_SHORT).show();
                }
                打破;}
}


解决方案

找到了一个非常简单的一点教程这里:

<一个href=\"http://www.$c$crzheaven.com/2012/04/22/create-simple-login-form-php-android-connect-php-android/\" rel=\"nofollow\">http://www.$c$crzheaven.com/2012/04/22/create-simple-login-form-php-android-connect-php-android/

感谢所有帮助@meda:)

Sorry for the (seemingly) lazy question, but i've been looking for a solution with no luck (in other words, I haven't found a solution that i understand).

I want to have users log in to an app by way of entering a username and password, this username and password has to match a username and password from the jsonarray which i've retrieved from a phpmyadmin database. The username and password have to be in the same row.

Here's the function I use to retrieve my jsonarray:

private void getData(){

JSONArray json;
try{
    user = editText1.getText().toString();
    password = editText2.getText().toString();

    json = readJsonFromUrl("http://localhost/indextest.php?function=getdata");

       Thread.sleep(1000);
  } catch (Exception e) {
    Log.e("BACKGROUND_PROC", e.getMessage());
  }

}

I just need to know how to search the jsonarray for the values that i retrieve from my textviews.

If possible I would like to retrieve a value that I can easily assign to an if statement like such:

public void onClick(View v) {

        switch (v.getId()) {
            case R.id.button1:

                if  ( editText1 != null && editText1.length() != 0 && editText2 != null && editText2.length() != 0){    
                    getData();
                    m_ProgressDialog = ProgressDialog.show(HomeScreen.this,    
                              "Please wait...", "Checking Details...", true);
                        m_ProgressDialog.setCancelable(true);

                      if ( /*username and password match*/){
                      Intent i = new Intent(this, Afterlog.class);
                      startActivity(i);     
                      }

                    else{
                        Toast.makeText(HomeScreen.this, "The username and password did not match any in our database...", Toast.LENGTH_SHORT).show();   
                    }
                }
                else {
                    Toast.makeText(HomeScreen.this, "Please enter a user name AND a password...", Toast.LENGTH_SHORT).show();
                }
                break;

}
}

解决方案

Found a very simple and to the point tutorial here:

http://www.coderzheaven.com/2012/04/22/create-simple-login-form-php-android-connect-php-android/

Thanks for all the help @meda :)

这篇关于从价值观和textviews比较JSONArray的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆