Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How do I display the results in a list view instead of it being displayed like i

ID: 3752570 • Letter: H

Question

How do I display the results in a list view instead of it being displayed like it is in the third image? The first image shows where the user enters their data, the second image shows the screen the user is taken to ("view" screen) when they select "view" from menu, and the third image shows what the user sees on the "view" screen. I want the information shown in the third image to be neatly shown in list view within the "view" screen.

//DatabaseManager.java

//Main Activity for view screen

//Main activity for adding data

//Content xml for adding data

//Menu for adding data screen

4{ 71% 8:39 pm VIEW BACK HOME Student ID: First Name: Last Name Gender: Course Study: Age: Address ADD STUDENT

Explanation / Answer

public void viewAll() { Cursor res = myDb.getAllDataStudent(); if(res.getCount() == 0) { message("Error","Nothing found"); return; } StringBuffer buffer = new StringBuffer(); while (res.moveToNext()) { buffer.append("Student "+ res.getString(0)+" "); buffer.append("Student ID:"+ res.getString(1)+" "); buffer.append("First Name:"+ res.getString(2)+" "); buffer.append("Last Name:"+ res.getString(3)+" "); buffer.append("Gender:"+ res.getString(4)+" "); buffer.append("Course Study:"+ res.getString(5)+" "); buffer.append("Age:"+ res.getString(6)+" "); buffer.append("Address:"+ res.getString(7)+" "); } // Show all data message("Data",buffer.toString()); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main2); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setTitle(null); myDb = new DatabaseManager(this); sid = (EditText)findViewById(R.id.sid); fn = (EditText)findViewById(R.id.fn); ln = (EditText)findViewById(R.id.ln); ge = (EditText)findViewById(R.id.ge); cs = (EditText)findViewById(R.id.cs); ag = (EditText)findViewById(R.id.ag); ad = (EditText)findViewById(R.id.ad); btnAdd = (Button)findViewById(R.id.add_button); AddData(); } public void AddData() { btnAdd.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { boolean isInserted = myDb.insertDataStudent( Integer.parseInt(sid.getText().toString()), fn.getText().toString(), ln.getText().toString(), ge.getText().toString(), cs.getText().toString(), Integer.parseInt(ag.getText().toString()), ad.getText().toString() ); if(isInserted == true) Toast.makeText(screen2.this,"Data Inserted",Toast.LENGTH_LONG).show(); else Toast.makeText(screen2.this,"Data not Inserted",Toast.LENGTH_LONG).show(); } } ); } /* public void showMessage(String title,String Message){ AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setCancelable(true); builder.setTitle(title); builder.setMessage(Message); builder.show(); } */ @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.screen2_menu, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.view) { Intent intent = new Intent(screen2.this, screen4.class); startActivity(intent); return true; }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote