(Preference)Activity in TabActivity

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

(Preference)Activity in TabActivity

Postby VIDEN » Mon Jun 15, 2009 10:11 am

Hey,

this seems like a really dumb question but I have searched the internet and didn't find anything useful...

I am trying to implement a PreferenceActivity as one of my Tabs in my TabActivity... since TabActivity extends ActivityGroup this shouldn't be a problem.... I just can't find a good example of how to implement it...

Does any one have an source example of how to embed an Activity in a Tab? That would be all I kneed.

Greets

David
VIDEN
Developer
Developer
 
Posts: 32
Joined: Tue May 12, 2009 9:39 am
Location: Germany

Top

Postby arams » Mon Jun 15, 2009 1:16 pm

I did not know what u ask...


CLASS---MULTIPLETABS

package com.rams;

import java.util.Stack;

import android.app.Activity;
import android.app.TabActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;

public class MultipleTaps extends TabActivity {


public static TabActivity ty;
@Override
public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
final TabHost tabHost = getTabHost();

TabSpec ts=tabHost.newTabSpec("Tab1");

tabHost.addTab(ts.setIndicator("List1").setContent(new Intent(this, CView.class)));
tabHost.addTab(tabHost.newTabSpec("Tab2").setIndicator("List2").setContent(new Intent(this, CView.class)));



}

}



CLASS--CVIEW

package com.rams;


import android.app.Activity;
import android.app.ListActivity;
import android.app.TabActivity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnKeyListener;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;

import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.Toast;

import android.widget.AdapterView.OnItemClickListener;


public class CView extends ListActivity implements OnItemClickListener{

public ListView lView;
public String[] list={"aaaaa "," bbbbbbb","cccccc ","ddd","eeee","ffffff"};
protected Vector objList;
public Context context;
public ArrayAdapter adap;
public int i=0;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
lView=new ListView(this);
adap=new ArrayAdapter(this,android.R.layout.simple_list_item_1,list);
this.setListAdapter(adap);
this.getListView().setOnItemClickListener(this);
}

public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
// TODO Auto-generated method stub
Toast.makeText(c,"ItemClick",Toast.LENGTH_SHORT).show();

}

}


I just send you how to create tabview....
arams
Experienced Developer
Experienced Developer
 
Posts: 89
Joined: Fri May 08, 2009 7:45 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 5 guests