您好,我只想问一下这段代码,问题是我只想getData在EditTextview. 但这只是祝酒词,您认为我的代码需要进行哪些修改才能将数据调用到getData非常EditText感谢您的帮助中。
package com.example.serviceapplication;
import android.database.Cursor;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
public class Timeinsms extends AppCompatActivity {
DatabaseHelper myDb;
EditText editTextId,editTextsmsi;
Button btngetData,btnView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_timeinsms);
myDb = new DatabaseHelper(this);
editTextId = (EditText) findViewById(R.id.editText_idin);
btngetData = (Button) findViewById(R.id.button_view);
btnView = (Button) findViewById(R.id.button_viewALL);
getData();
viewAll();
}
public void getData() {
btngetData.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String id = editTextId.getText().toString();
if (id.equals(String.valueOf(""))) {
editTextId.setError("Enter id to get data");
return;
}
Cursor res = myDb.getData(id);
String data = null;
if (res.moveToFirst()) {
data =
"Id:" + res.getString(0) + "\n\n" +
"Time In :" + res.getString(1) + "\n\n" +
"Customer :" + res.getString(2) + "\n\n"+
"Branch :" + res.getString(3) + "\n\n"+
"Machine :" + res.getString(4) + "\n\n";
}
showMessage("TIME OUT FORM"+"\n\n", data);
}
});
}
眼眸繁星
相关分类