學習安卓開發時間:30分鐘
程式碼量:100
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.MyApplication2"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.MyApplication2"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
package com.example.myapplication2;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.example.myapplication2.MysqlHelp;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private Button myButtonlogin;
private EditText classq,teacher,didian;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myButtonlogin = findViewById(R.id.et5);
myButtonlogin.setOnClickListener(this);
}
public void onClick(View view) {
classq = findViewById(R.id.et2);
teacher = findViewById(R.id.et3);
didian = findViewById(R.id.et4);
String id = classq.getText().toString();
String name = teacher.getText().toString();
String phone = didian.getText().toString();
MysqlHelp.insertData(id, name, phone);
}
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.example.myapplication2.MysqlHelp;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private Button myButtonlogin;
private EditText classq,teacher,didian;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myButtonlogin = findViewById(R.id.et5);
myButtonlogin.setOnClickListener(this);
}
public void onClick(View view) {
classq = findViewById(R.id.et2);
teacher = findViewById(R.id.et3);
didian = findViewById(R.id.et4);
String id = classq.getText().toString();
String name = teacher.getText().toString();
String phone = didian.getText().toString();
MysqlHelp.insertData(id, name, phone);
}