简体   繁体   English

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

[英]I am trying to make a social media app. How do I connect my app to a mySql and, Xampp?

Here is my code for my register java: 这是我的注册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. 我要存储st名称,姓氏,用户名,电子邮件,出生日期和密码。 How do I do that. 我怎么做。 I can't to the tutorials on this because ArrayList NameValuePair has been deprecated. 由于ArrayList NameValuePair已被弃用,因此我无法上教程。

First you need to create php web services which sends output in JSON format. 首先,您需要创建php Web服务,该服务以JSON格式发送输出。 In adroid app i recommend you to use android volley library. 在adroid应用中,我建议您使用android volley库。

Volley is an HTTP library that makes networking for Android apps easier and most importantly, faster. Volley是一个HTTP库,可简化Android应用程序的联网,最重要的是,可以更快地联网。 Volley is available through the open AOSP repository. 可通过开放的AOSP存储库获得Volley。

Read more about volley Also here is tutorial about volley and mysql connection Volley mysql 阅读有关volley的更多信息这也是有关volley和mysql连接的教程Volley mysql

Apart from Volley library, you can also use Retrofit library and see its tutorials, this tutorial is really helpful. 除了Volley库,您还可以使用Retrofit库并查看其教程, 教程确实很有帮助。 These 2 libraries are currently the most used libraries helping server client communication. 这两个库是当前最常用的可帮助服务器客户端通信的库。

If you do not want to use a 3rd party library, you can use AsyncTasks in your Activity. 如果您不想使用第三方库,则可以在“活动”中使用AsyncTasks。 This can be a good starting tutorial if you are new to php mysql integration. 如果您不熟悉php mysql集成,那么可能是一个很好的入门教程。 Wamp and xammp are similar, you don't need to worry about that. Wamp和xammp相似,您不必为此担心。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将我的Android应用程序连接到远程MySQL数据库? - How do I connect my Android app to a remote MySQL database? 我想通过在当前应用程序中按一个按钮来终止/关闭特定应用程序。 我怎样才能做到这一点? - I want to kill/ close a particular app by pressing a button in my current app. How can I do this? 如何托管android应用。 我正在使用mysql和Tomcat服务器 - How to host android app. I am using mysql and Tomcat server 我正在努力使我的应用程序具有“保持登录状态”状态。 我该怎么办? - I'm working on having a “Keep me on Logged in” state on my app. How should i do it? 我正在制作一个壁纸应用程序。 我被困在某个地方 - I am making an wallpaper app. And I am stuck somewhere 我在测试我的应用程序时遇到了这个崩溃。 我是一个完整的初学者,无法理解如何解决这个问题,有什么解决方案吗? - I have this crash while testing my app. I am a complete beginner and cant understand how to fix this, any solution? 我的计时器应用程序中出现很多错误。 他们中的大多数似乎是因为资源是私有的 - I am getting a lot of Errors in my Timer App. Most of them seem to be because the resource is private 我想在Java应用程序和Xampp之间建立连接 - I want to connect between Java app and Xampp 如何使用Android应用程序连接到MySQL数据库? - How can i connect to my MySQL database with an android app? 如何让我的应用程序出现在app chooser中? - How do I make my app appear in app chooser?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM