- Forum posts: 8
Apr 5, 2014, 10:39:45 AM via Website
Apr 5, 2014 10:39:45 AM via Website
Thank you in advance.
Apr 5, 2014, 10:39:45 AM via Website
Apr 5, 2014 10:39:45 AM via Website
Apr 7, 2014, 6:43:52 AM via Website
Apr 7, 2014 6:43:52 AM via Website
— modified on Apr 7, 2014, 6:50:15 AM
Forum Rules - Recommended for new AndroidPIT members! / Important to all community members: please read before posting
Jun 15, 2014, 6:00:55 AM via Website
Jun 15, 2014 6:00:55 AM via Website
John Farrell
Well if you want to pull the data from that table and list it in the ListView(MainActivity) of my Android app when it's launched(onCreate).
I'm using a a list of items which is premade by me
items table(in mydb database)
id, name, model, year of manufacture, pricepackage com.example.myproject;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;public class MainActivity extends Activity implements OnItemClickListener {
protected String[] items = {"Pen", "Pencil", "Sharpener", "Paper"}; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ListAdapter adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, items); ListView carsList = (ListView) findViewById(R.id.listitems); itemsList.setAdapter(adapter); ListView list = (ListView) findViewById(R.id.listitems); list.setOnItemClickListener(this); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main, menu); return true; } public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { Intent intent = new Intent(this, DetailsActivity.class); startActivity(intent); }
}
Hello John,
Thank you for this,sorry for being late reply i forgot my account...Thank you again.
Recommended editorial content
With your consent, external content is loaded here.
By clicking on the button above, you agree that external content may be displayed to you. Personal data may be transmitted to third-party providers in the process. You can find more information about this in our Privacy Policy.