手机常识汇总
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.kroz.tag" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <uses-library android:name="com.google.android.maps"/> <activity android:name=".AppMain" 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="MapTabView" android:label="@string/mapview_name"> <intent-filter> <category android:name="android.intent.category.EMBED"></category> <action android:name="android.intent.action.MAIN"></action> </intent-filter> </activity> </application> <uses-sdk android:minSdkVersion="3"/> <uses-permission android:name="android.permission.INTERNET"></uses-permission> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission> <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"></uses-permission> </manifest>
这里面有两个方法 其实说来还是一样的
1.
public class BS_Main extends TabActivity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TabHost tabHost = getTabHost(); tabHost.addTab(tabHost.newTabSpec("tab1").setContent(R.id.mapview).setIndicator("mapview_name",getResources().getDrawable(R.drawable.map_icon))); tabHost.addTab(tabHost.newTabSpec("tab2").setContent(R.id.anotherview).setIndicator("tab2_name",getResources().getDrawable(R.drawable.anotherview_icon))); } }
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="fill_parent" />
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:id="@android:id/tabcontent"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<mapview tag here with ur map Api key>
<anotherview tag>
</FrameLayout>
2.Main.xml
<?xml version="1.0" encoding="utf-8"?> <TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content"/> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent"> <RelativeLayout android:id="@+id/emptylayout1" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"/> <TextView android:id="@+id/textview2" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="Details Details Details Details"/> </FrameLayout> </LinearLayout> </TabHost>
Maptabview.xml
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/maptablayout" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <com.google.android.maps.MapView android:id="@+id/mapview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:clickable="true" android:apiKey="0pFtdSwta8EMTfArj32ycOw2kZg0LSEqa4fUGFA"/> </RelativeLayout>
package com.kroz.tag;
import android.app.TabActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.FrameLayout;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
public class AppMain extends TabActivity {
TabHost mTabHost;
FrameLayout mFrameLayout;
/** Called when the activity is first created.*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mTabHost = getTabHost();
TabSpec tabSpec = mTabHost.newTabSpec("tab_test1");
tabSpec.setIndicator("Map");
Context ctx = this.getApplicationContext();
Intent i = new Intent(ctx, MapTabView.class);
tabSpec.setContent(i);
mTabHost.addTab(tabSpec);
mTabHost.addTab(mTabHost.newTabSpec("tab_test2").setIndicator("Details").setContent(R.id.textview2));
mTabHost.setCurrentTab(0);
}
}
package com.kroz.tag;
import android.os.Bundle;
import com.google.android.maps.MapActivity;
public class MapTabView extends MapActivity {
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.maptabview);
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
}
ContentValues values = new ContentValues(); values.put(MediaStore.MediaColumns.DATA, <<asbolutePathToYourAudioFileHere>>); values.put(MediaStore.MediaColumns.TITLE, "<<yourRingToneNameHere>>"); values.put(MediaStore.MediaColumns.SIZE, k); values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/mpeg"); // assuming it's an mpeg, of course values.put(MediaStore.Audio.Media.ARTIST, "<<yourArtistNameHere>>"); // values.put(MediaStore.Audio.Media.DURATION, duration); // doesn't appear to be necessary if you don't know values.put(MediaStore.Audio.Media.IS_RINGTONE, true); Uri uri = MediaStore.Audio.Media.getContentUriForPath(outPath); Uri newUri = getContentResolver().insert(uri, values); RingtoneManager.setActualDefaultRingtoneUri( <<MyActivity>>.this, RingtoneManager.TYPE_RINGTONE, newUri);
File k = new File(path, "mysong.mp3"); // path is a file to /sdcard/media/ringtone ContentValues values = new ContentValues(); values.put(MediaStore.MediaColumns.DATA, k.getAbsolutePath()); values.put(MediaStore.MediaColumns.TITLE, "My Song title"); values.put(MediaStore.MediaColumns.SIZE, 215454); values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/mp3"); values.put(MediaStore.Audio.Media.ARTIST, "Madonna"); values.put(MediaStore.Audio.Media.DURATION, 230); values.put(MediaStore.Audio.Media.IS_RINGTONE, true); values.put(MediaStore.Audio.Media.IS_NOTIFICATION, false); values.put(MediaStore.Audio.Media.IS_ALARM, false); values.put(MediaStore.Audio.Media.IS_MUSIC, false); //Insert it into the database Uri uri = MediaStore.Audio.Media.getContentUriForPath(k.getAbsolutePath()); Uri newUri = main.getContentResolver().insert(uri, values); RingtoneManager.setActualDefaultRingtoneUri( myActivity, RingtoneManager.TYPE_RINGTONE, newUri );