Linking two Views

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Linking two Views

Postby trainstroker » Tue Nov 17, 2009 6:12 am

I'm a newbie to Android programming, and am having trouble linking two views. I have a TabGroup and the content of one of the tabs is set to be a ListView. The two work great independently, but when I try to link them with an Intent, Android crashes. Please help. Most/All of this code is ripped from somewhere. Browser.java is launched first.

Here is the code:

Browser.java
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. package com.pv.x;
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10. import android.app.TabActivity;
  11.  
  12. import android.os.Bundle;
  13.  
  14. import android.widget.TabHost;
  15.  
  16. import android.content.Intent;
  17.  
  18. import android.view.LayoutInflater;
  19.  
  20. import com.pv.x.List1;
  21.  
  22.  
  23.  
  24. public class Browser extends TabActivity {
  25.  
  26.         @Override
  27.  
  28.         protected void onCreate(Bundle savedInstanceState) {
  29.  
  30.             super.onCreate(savedInstanceState);
  31.  
  32.             TabHost tabHost = getTabHost();
  33.  
  34.            
  35.  
  36.             LayoutInflater.from(this).inflate(R.layout.tabs, tabHost.getTabContentView(), true);
  37.  
  38.  
  39.  
  40.             tabHost.addTab(tabHost.newTabSpec("tab1")
  41.  
  42.                     .setIndicator("tab1")
  43.  
  44.                     .setContent(R.id.view1));
  45.  
  46.             tabHost.addTab(tabHost.newTabSpec("tab2")
  47.  
  48.                     .setIndicator("tab2")
  49.  
  50.                     .setContent(new Intent(this,List1.class)));
  51.  
  52.         }
  53.  
  54. }
  55.  
  56.  
Parsed in 0.035 seconds, using GeSHi 1.0.8.4

List1.java (copy paste from APIDemo)
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. package com.pv.x;
  3.  
  4.  
  5.  
  6. import android.app.ListActivity;
  7.  
  8. import android.os.Bundle;
  9.  
  10. import android.widget.ArrayAdapter;
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18. /**
  19.  
  20.  * A list view example where the
  21.  
  22.  * data for the list comes from an array of strings.
  23.  
  24.  */
  25.  
  26. public class List1 extends ListActivity {
  27.  
  28.  
  29.  
  30.     public void onCreate(Bundle savedInstanceState) {
  31.  
  32.         super.onCreate(savedInstanceState);
  33.  
  34.  
  35.  
  36.         // Use an existing ListAdapter that will map an array
  37.  
  38.         // of strings to TextViews
  39.  
  40.         setListAdapter(new ArrayAdapter<String>(this,
  41.  
  42.                 android.R.layout.simple_list_item_1, mStrings));
  43.  
  44.         getListView().setTextFilterEnabled(true);
  45.  
  46.     }
  47.  
  48.  
  49.  
  50.     private String[] mStrings = {
  51.  
  52.             "Abbaye de Belloc", "Abbaye du Mont des Cats", "Abertam", "Abondance", "Ackawi",
  53.  
  54.             "Acorn", "Adelost", "Affidelice au Chablis", "Afuega'l Pitu", "Airag", "Airedale",
  55.  
  56.             "Aisy Cendre", "Allgauer Emmentaler", "Alverca", "Ambert", "American Cheese",
  57.  
  58.             "Ami du Chambertin", "Anejo Enchilado", "Anneau du Vic-Bilh", "Anthoriro", "Appenzell",
  59.  
  60.             "Aragon", "Ardi Gasna", "Ardrahan", "Armenian String", "Aromes au Gene de Marc",
  61.  
  62.             "Asadero", "Asiago", "Aubisque Pyrenees", "Autun", "Avaxtskyr", "Baby Swiss",
  63.  
  64.             "Babybel", "Baguette Laonnaise", "Bakers", "Baladi", "Balaton", "Bandal", "Banon",
  65.  
  66.             "Barry's Bay Cheddar", "Basing", "Basket Cheese", "Bath Cheese", "Bavarian Bergkase",
  67.  
  68.             "Baylough", "Beaufort", "Beauvoorde", "Beenleigh Blue", "Beer Cheese", "Bel Paese",
  69.  
  70.             "Bergader", "Bergere Bleue", "Berkswell", "Beyaz Peynir", "Bierkase", "Bishop Kennedy",
  71.  
  72.             "Blarney", "Bleu d'Auvergne", "Bleu de Gex", "Bleu de Laqueuille",
  73.  
  74.             "Bleu de Septmoncel", "Bleu Des Causses", "Blue", "Blue Castello", "Blue Rathgore",
  75.  
  76.             "Blue Vein (Australian)", "Blue Vein Cheeses", "Bocconcini", "Bocconcini (Australian)",
  77.  
  78.             "Boeren Leidenkaas", "Bonchester", "Bosworth", "Bougon", "Boule Du Roves",
  79.  
  80.             "Boulette d'Avesnes", "Boursault", "Boursin", "Bouyssou", "Bra", "Braudostur",
  81.  
  82.             "Breakfast Cheese", "Brebis du Lavort", "Brebis du Lochois", "Brebis du Puyfaucon",
  83.  
  84.             "Bresse Bleu", "Brick", "Brie", "Brie de Meaux", "Brie de Melun", "Brillat-Savarin",
  85.  
  86.             "Brin", "Brin d' Amour", "Brin d'Amour", "Brinza (Burduf Brinza)",
  87.  
  88.             "Briquette de Brebis", "Briquette du Forez", "Broccio", "Broccio Demi-Affine",
  89.  
  90.             "Brousse du Rove", "Bruder Basil", "Brusselae Kaas (Fromage de Bruxelles)", "Bryndza",
  91.  
  92.             "Buchette d'Anjou", "Buffalo", "Burgos", "Butte", "Butterkase", "Button (Innes)",
  93.  
  94.             "Buxton Blue", "Cabecou", "Caboc", "Cabrales", "Cachaille", "Caciocavallo", "Caciotta",
  95.  
  96.             "Caerphilly", "Cairnsmore", "Calenzana", "Cambazola", "Camembert de Normandie",
  97.  
  98.             "Canadian Cheddar", "Canestrato", "Cantal", "Caprice des Dieux", "Capricorn Goat",
  99.  
  100.             "Capriole Banon", "Carre de l'Est", "Casciotta di Urbino", "Cashel Blue", "Castellano",
  101.  
  102.             "Castelleno", "Castelmagno", "Castelo Branco", "Castigliano", "Cathelain",
  103.  
  104.             "Celtic Promise", "Cendre d'Olivet", "Cerney", "Chabichou", "Chabichou du Poitou",
  105.  
  106.             "Chabis de Gatine", "Chaource", "Charolais", "Chaumes", "Cheddar",
  107.  
  108.             "Cheddar Clothbound", "Cheshire", "Chevres", "Chevrotin des Aravis", "Chontaleno",
  109.  
  110.             "Civray", "Coeur de Camembert au Calvados", "Coeur de Chevre", "Colby", "Cold Pack",
  111.  
  112.             "Comte", "Coolea", "Cooleney", "Coquetdale", "Corleggy", "Cornish Pepper",
  113.  
  114.             "Cotherstone", "Cotija", "Cottage Cheese", "Cottage Cheese (Australian)",
  115.  
  116.             "Cougar Gold", "Coulommiers", "Coverdale", "Crayeux de Roncq", "Cream Cheese",
  117.  
  118.             "Cream Havarti", "Crema Agria", "Crema Mexicana", "Creme Fraiche", "Crescenza",
  119.  
  120.             "Croghan", "Crottin de Chavignol", "Crottin du Chavignol", "Crowdie", "Crowley",
  121.  
  122.             "Cuajada", "Curd", "Cure Nantais", "Curworthy", "Cwmtawe Pecorino",
  123.  
  124.             "Cypress Grove Chevre", "Danablu (Danish Blue)", "Danbo", "Danish Fontina",
  125.  
  126.             "Daralagjazsky", "Dauphin", "Delice des Fiouves", "Denhany Dorset Drum", "Derby",
  127.  
  128.             "Dessertnyj Belyj", "Devon Blue", "Devon Garland", "Dolcelatte", "Doolin",
  129.  
  130.             "Doppelrhamstufel", "Dorset Blue Vinney", "Double Gloucester", "Double Worcester",
  131.  
  132.             "Dreux a la Feuille", "Dry Jack", "Duddleswell", "Dunbarra", "Dunlop", "Dunsyre Blue",
  133.  
  134.             "Duroblando", "Durrus", "Dutch Mimolette (Commissiekaas)", "Edam", "Edelpilz",
  135.  
  136.             "Emental Grand Cru", "Emlett", "Emmental", "Epoisses de Bourgogne", "Esbareich"};
  137.  
  138. }
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
Parsed in 0.062 seconds, using GeSHi 1.0.8.4
trainstroker
Freshman
Freshman
 
Posts: 3
Joined: Tue Nov 17, 2009 6:04 am

Top

Postby trainstroker » Tue Nov 17, 2009 2:25 pm

spent a good 4 hours on this, have no idea what I did. it's working now. i possibly may have added my list1 to the manifest, and i also reinstalled eclipse (but that's because it was being unbearably slow). thanks for everything haha !
trainstroker
Freshman
Freshman
 
Posts: 3
Joined: Tue Nov 17, 2009 6:04 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 8 guests