[英]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.