Pythontr

husonet | Tarih: 17.04.2024

Android Scripts tab oluşturma

Android Scripts tab oluşturma örnek (TabActivity)

main.java


import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;

public class RehberKontrol extends TabActivity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

TabHost tabHost = (TabHost) findViewById(android.R.id.tabhost);
Intent intent;
TabSpec ilkTab;
TabSpec ikinciTab;

intent = new Intent().setClass(this, ilkTab.class);
ilkTab = tabHost.newTabSpec("tabKategori").setIndicator("Kategori").setContent(intent);

intent = new Intent().setClass(this, ikinciTab.class);
ikinciTab = tabHost.newTabSpec("tabKategori").setIndicator("Ayarlar").setContent(intent);

tabHost.addTab(ilkTab);
tabHost.addTab(ikinciTab);
}
}

{reklam}

ilkTab.java


import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class ilkTab extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
TextView textView = new TextView(this);
textView.setText("Birinci Tab");
setContentView(textView);
}
}


ikinciTab.java


import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class ikinciTab extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
TextView textView = new TextView(this);
textView.setText("İkinci Tab");
setContentView(textView);
}
}


AndroidManifest.xml


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.rehber.kontrol"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar">
<activity
android:name=".RehberKontrol"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ilkTab"></activity>
<activity android:name=".ikinciTab"></activity>
</application>
</manifest>


main.xml


<?xml version="1.0" encoding="utf-8"?>
<TabHost android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost">

<LinearLayout android:id="@+id/LinearLayout01"
android:orientation="vertical"
android:layout_height="fill_parent"
android:layout_width="fill_parent">

<TabWidget android:id="@android:id/tabs"
android:layout_height="wrap_content"
android:layout_width="fill_parent"/>

<FrameLayout android:id="@android:id/tabcontent"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
</FrameLayout>
</LinearLayout>
</TabHost>