douzhuolong9886 2015-12-15 22:23
浏览 42
已采纳

我正在尝试制作社交媒体应用。 如何将我的应用程序连接到mySql和Xampp?

Here is my code for my register java:

public class Register extends AppCompatActivity {

Button bRR;
EditText etFN, etLN, etEmail, etUN, etPW, etRPW;
Spinner SMonth, SDay, SYaer;
TextView TVterms;
ArrayAdapter<CharSequence> adapter;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_register);
    initTypeface();

    //Button's go here
    bRR = (Button)findViewById(R.id.bRR);

    bRR = (Button)findViewById(R.id.bRR);
    bRR.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/SinkinSans-300Light.otf"));
    //EditText's go here
    etFN = (EditText)findViewById(R.id.etFN);
    etLN = (EditText)findViewById(R.id.etLN);
    etEmail = (EditText)findViewById(R.id.etEmail);
    etUN = (EditText)findViewById(R.id.etUN);
    etPW = (EditText)findViewById(R.id.etPW);
    etRPW = (EditText)findViewById(R.id.etRPW);
    //Spinner's go here
    SMonth = (Spinner)findViewById(R.id.SMonth);
    SDay = (Spinner)findViewById(R.id.SDay);
    SYaer = (Spinner)findViewById(R.id.SYear);

    SMonth = (Spinner)findViewById(R.id.SMonth);
    adapter = ArrayAdapter.createFromResource(this, R.array.Month, R.layout.support_simple_spinner_dropdown_item);
    adapter.setDropDownViewResource(R.layout.support_simple_spinner_dropdown_item);
    SMonth.setAdapter(adapter);

    SDay = (Spinner)findViewById(R.id.SDay);
    adapter = ArrayAdapter.createFromResource(this, R.array.Day, R.layout.support_simple_spinner_dropdown_item);
    adapter.setDropDownViewResource(R.layout.support_simple_spinner_dropdown_item);
    SDay.setAdapter(adapter);

    SYaer = (Spinner)findViewById(R.id.SYear);
    adapter = ArrayAdapter.createFromResource(this, R.array.Year, R.layout.support_simple_spinner_dropdown_item);
    adapter.setDropDownViewResource(R.layout.support_simple_spinner_dropdown_item);
    SYaer.setAdapter(adapter);
    //TextView's go here
    TVterms = (TextView)findViewById(R.id.TVterms);
}
public void onSignUpClick(View v)
{
    if (v.getId() == R.id.bRR);
    {
        EditText fname = (EditText)findViewById(R.id.etFN);
        EditText lname = (EditText)findViewById(R.id.etLN);
        EditText uname = (EditText)findViewById(R.id.etUN);
        EditText email = (EditText)findViewById(R.id.etEmail);
        EditText pass1 = (EditText)findViewById(R.id.etPW);
        EditText pass2 = (EditText)findViewById(R.id.etRPW);

        String fnamestr = fname.getText().toString();
        String lnamestr = lname.getText().toString();
        String unamestr = uname.getText().toString();
        String emailstr = email.getText().toString();
        String pass1str = pass1.getText().toString();
        String pass2str = pass2.getText().toString();

        if (!pass1str.equals(pass2str))
        {
            //popup msg
            Toast pass = Toast.makeText(Register.this, "Password do not match!", Toast.LENGTH_SHORT);
            pass.show();

        }

    }
}

private void initTypeface() {

    Typeface myTypeface = Typeface.createFromAsset(getAssets(), "fonts/SinkinSans-300Light.otf");
    TextView tittleText=(TextView) findViewById(R.id.textView5);
    tittleText.setTypeface(myTypeface);

    myTypeface = Typeface.createFromAsset(getAssets(), "fonts/SinkinSans-300Light.otf");
    tittleText = (TextView) findViewById(R.id.textView7);
    tittleText.setTypeface(myTypeface);

    myTypeface = Typeface.createFromAsset(getAssets(), "fonts/SinkinSans-300Light.otf");
    tittleText = (TextView) findViewById(R.id.textView8);
    tittleText.setTypeface(myTypeface);

    myTypeface = Typeface.createFromAsset(getAssets(), "fonts/SinkinSans-300Light.otf");
    tittleText = (TextView) findViewById(R.id.textView9);
    tittleText.setTypeface(myTypeface);

    myTypeface = Typeface.createFromAsset(getAssets(), "fonts/SinkinSans-300Light.otf");
    tittleText = (TextView) findViewById(R.id.textView10);
    tittleText.setTypeface(myTypeface);

    myTypeface = Typeface.createFromAsset(getAssets(), "fonts/SinkinSans-300Light.otf");
    tittleText = (TextView) findViewById(R.id.textView11);
    tittleText.setTypeface(myTypeface);

    myTypeface = Typeface.createFromAsset(getAssets(), "fonts/SinkinSans-300Light.otf");
    tittleText = (TextView) findViewById(R.id.textView12);
    tittleText.setTypeface(myTypeface);

    myTypeface = Typeface.createFromAsset(getAssets(), "fonts/SinkinSans-300Light.otf");
    tittleText = (TextView) findViewById(R.id.textView13);
    tittleText.setTypeface(myTypeface);

    myTypeface = Typeface.createFromAsset(getAssets(), "fonts/SinkinSans-300Light.otf");
    tittleText = (TextView) findViewById(R.id.TVterms);
    tittleText.setTypeface(myTypeface);
}
}

I want to store the st name, last name, username, email, date of birth and password. How do I do that. I can't to the tutorials on this because ArrayList NameValuePair has been deprecated.

  • 写回答

2条回答 默认 最新

  • dousui6488 2015-12-15 22:43
    关注

    First you need to create php web services which sends output in JSON format. In adroid app i recommend you to use android volley library.

    Volley is an HTTP library that makes networking for Android apps easier and most importantly, faster. Volley is available through the open AOSP repository.

    Read more about volley Also here is tutorial about volley and mysql connection Volley mysql

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题