parent
361ace274c
commit
c9bc58dd18
@ -0,0 +1,55 @@
|
||||
package edu.hzuapps.shudongapp;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.ListAdapter;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import edu.hzuapps.shudongapp.bean.User;
|
||||
|
||||
public class chakan extends AppCompatActivity {
|
||||
|
||||
private EditText ed_name_Search;
|
||||
private TextView tvResult;
|
||||
private MySQLiteOpenHelper mySQLiteOpenHelper;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_chakan);
|
||||
|
||||
ed_name_Search = findViewById(R.id.ed_name_search);
|
||||
tvResult = findViewById(R.id.tv_search_1);
|
||||
mySQLiteOpenHelper = new MySQLiteOpenHelper(this);
|
||||
}
|
||||
|
||||
public void querydata(View view) {
|
||||
String name = ed_name_Search.getText().toString().trim();
|
||||
|
||||
//按姓名从数据库中查询
|
||||
List<User> users = mySQLiteOpenHelper.queryFromDbByName(name);
|
||||
String result = "";
|
||||
for (User u : users){
|
||||
result+= "姓名:" + u.getName() + "\n" + u.getStory() + "\n";
|
||||
}
|
||||
|
||||
tvResult.setText(result);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in new issue