Buttons in a custom view when the custom view is in a tab

Dark_Peppe

New Member
THE QUESTIONIs it possible to run one tab from a different Activity or Java file than the other three, thus allowing me to connect the second Activity to the server that is running off of the first. Some information on my appWhat I have is a multiple tabbed app, with a few different layouts. One of them is an interactive graphical layout. On this tab most of it needs to be a custom view that I have set up to work already but I need a row of widgets on the bottom like buttons, sliders etc. I am now at the point where if I run the graphical layout by setting it as the main activity (\[code\]android:name=".Tab3Activity"\[/code\]) in the manifest the app will run and print out text when I click on the button how ever if I run it from the tab as I need it to run the app will crash when I click on the button. Here is the code I have currently Tab set up\[code\] th.setup(); TabSpec specs = th.newTabSpec("tag0"); specs.setContent(R.id.connecttionTab); specs.setIndicator("Connection Tab"); th.addTab(specs); specs = th.newTabSpec("tag1"); specs.setContent(R.id.tab1); specs.setIndicator("Zone Manager"); th.addTab(specs); specs = th.newTabSpec("tag2"); specs.setContent(R.id.tab2); specs.setIndicator("",res.getDrawable(R.drawable.ic_tab_vaccontrol)); th.addTab(specs); //Intent intent = new Intent().setClass(this, Tab3Activity.class); tryed using this but //with this tab goes ontop of all the other ones and still doesnt work. TabSpec spec = th.newTabSpec("Tab3").setIndicator("Graphical Layout").setContent(R.id.tab3); th.addTab(spec);\[/code\]Tab3Activity\[code\]public class Tab3Activity extends Activity { private Tab3 mTab3; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.tab3); mTab3 = (Tab3) findViewById(R.id.tab3_display); } public void onAddZone(View view) { mTab3.addZone(); }}\[/code\]Tab3 (view class)\[code\]public class Tab3 extends View implements OnTouchListener{ public Tab3(Context context, AttributeSet attrs) { super (context, attrs); setFocusable(true); setFocusableInTouchMode(true); setOnTouchListener(this); requestFocus(); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); //drawings invalidate(); } @Override public boolean onTouch(View v, MotionEvent event) { //onTouch return true; } public void addZone() { //String w = "W~20~0~0~0~0~0"; Log.d("ZoneSize", "Zone set"); //MyApplication.preferences.edit().putString( "ZoneSize", w ).commit(); //MyApplication.preferences.edit().putBoolean("ZoneSizeReady", true).commit(); }}\[/code\]XML\[code\]<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:id="@+id/myLayout" android:orientation="vertical" android:layout_height="match_parent" > <com.zone.manager.Tab3 android:id="@+id/tab3_display" android:layout_width="fill_parent" android:layout_height="620dp" /> <LinearLayout android:layout_width="match_parent" android:orientation="horizontal" android:layout_height="match_parent" > <Button android:id="@+id/addZone" android:layout_width="wrap_content" android:onClick="onAddZone" android:layout_height="wrap_content" android:text="Add Zone" /> <Button android:id="@+id/helpZone" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Help" /> <SeekBar android:id="@+id/seekBar1" android:paddingTop="9dp" android:layout_width="179dp" android:layout_height="wrap_content" /> </LinearLayout></LinearLayout>\[/code\]Thanks for any help you may give to me!
 
Back
Top