Splitting the Tab
Here is the complete source code to our LunchList activity, after all of the
changes made in this tutorial:
package apt.tutorial;
import android.app.TabActivity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.LayoutInflater;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RadioGroup;
import android.widget.TabHost;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
public class LunchList extends TabActivity {
List<Restaurant> model=new ArrayList<Restaurant>();
RestaurantAdapter adapter=null;
EditText name=null;
EditText address=null;
RadioGroup types=null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
name=(EditText)findViewById(R.id.name);
address=(EditText)findViewById(R.id.addr);
types=(RadioGroup)findViewById(R.id.types);
Button save=(Button)findViewById(R.id.save);
save.setOnClickListener(onSave);
ListView list=(ListView)findViewById(R.id.restaurants);
adapter=new RestaurantAdapter();
list.setAdapter(adapter);
TabHost.TabSpec spec=getTabHost().newTabSpec("tag1");
spec.setContent(R.id.restaurants);
spec.setIndicator("List", getResources()
.getDrawable(R.drawable.list));
getTabHost().addTab(spec);