Question

Im trying to make a travel phrase application in android in 2 different languages. where in the first screen user selects which language to use. language selections can be in any layout. (grids, listview, button or tab).
and from there im trying to call another listview with the phrases. and from the listview with phrases call another activity with the definition and pronunciations.

Apparently im doing tab with listview. Cant understand how to connect this tabactivity and listactivity. Ive searched from the internet, read a book but no help. Please help

This is the tab activity

public class Screen31 extends TabActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    TabHost tabHost = getTabHost();

    LayoutInflater inflater = getLayoutInflater();
    inflater.inflate(
        R.layout.sample1,
        tabHost.getTabContentView(),
        true
    );
    inflater.inflate(
        R.layout.sample2,
        tabHost.getTabContentView(),
        true
    );


    TabSpec tab1 = tabHost.newTabSpec("tab1");
    tab1.setIndicator("Japanese");
    tab1.setContent(R.id.tab1);
    TabSpec tab2 = tabHost.newTabSpec("tab2");
    tab2.setIndicator("English");

    tab2.setContent(R.id.tab2);


    tabHost.addTab(tab1);
    tabHost.addTab(tab2);

}

}

and this is the listview activity

public class ListView10 extends ListActivity {

public void onCreate(Bundle icicle) {
super.onCreate(icicle);
String[] values = new String[] { "japanese", "english" };
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
    android.R.layout.simple_list_item_1, values);

  setListAdapter(adapter);
 }


 @Override
protected void onListItemClick(ListView l, View v, int position, long id) {
String item = (String) getListAdapter().getItem(position);
Toast.makeText(this, item + " selected", Toast.LENGTH_LONG).show();
 }

}

and the layouts of sample 1 and sample 2 are completely different sample1 is a layout of a listview and sample 2 is linear with text. im keeping it different to see the change.

No correct solution

OTHER TIPS

First thing i would suggest do not use TabActivity use FragmentActivity and implements ActionBar.TabListener and you can refer this link

https://github.com/rameshkec85/BottomTabsFragmentTabHost

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top