1.
Hello
Google MAP:
Cmd > cd
/C:/program File/ Java/sdk/bin > keytool -list -alias androiddebugkey
-keystore C:\Users\sonnt\.android\debug.keystore -storepass android -keypass
android –v
Copy: chuỗi
MD5.
E9:2C:A5:2E:80:79:FF:CD:4B:DB:25:B0:8D:7C:AA:CE
Sẽ thu đựơc :
Cảm ơn bạn đã đăng ký khóa
Android Maps API!
Khoá của bạn là:
0qM3SvB2qp0QntwmC_nS582rZSmG8WYSBXteEGg
Khoá này phù hợp với tất cả các ứng
dụng được ký bằng chứng nhận có dấu vân tay:
E9:2C:A5:2E:80:79:FF:CD:4B:DB:25:B0:8D:7C:AA:CE
Đây là bố cục xml mẫu để bạn bắt
đầu tìm hiểu về ánh xạ:
<com.google.android.maps.MapView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="0qM3SvB2qp0QntwmC_nS582rZSmG8WYSBXteEGg"
them vào maníet.xml dòng sau :
<uses-library android:name =
“com.google.android.maps”/>
(nằm trong tab <application> </application>)
Activity extends MapActivity
2. JAVA MAP
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
public class MapExample {
public static void main(String[] args) {
Map<Object,String> mp=new HashMap<Object, String>();
// adding or set elements in Map by put method key and value pair
mp.put(new Integer(2), "Two");
mp.put(new Integer(1), "One");
mp.put(new Integer(3), "Three");
mp.put(new Integer(4), "Four");
//Get Map in Set interface to get key and value
Set s=mp.entrySet();
//Move next key and value of Map by iterator
Iterator it=s.iterator();
while(it.hasNext())
{
// key=value separator this by Map.Entry to get key and value
Map.Entry m =(Map.Entry)it.next();
// getKey is used to get key of Map
int key=(Integer)m.getKey();
// getValue is used to get value of key in Map
String value=(String)m.getValue();
System.out.println("Key :"+key+" Value :"+value);
}
}
}
3.
Google Analytics SDK for Android
https://developers.google.com/analytics/devguides/collection/android/devguide?hl=vi-VN
4. Tabhost
extend activity
|
Check Permisstion:
if (context.checkCallingOrSelfPermission(Manifest.permission.INTERNET)
!= PackageManager.PERMISSION_GRANTED) {
-
Handle and Thead
private Handler
messageHandler = new Handler() {
};
public void
handleMessage(Message msg) {
super.handleMessage(msg); progressDialog.dismiss(); }
start = (Button)
findViewById(R.id.Button01);
start.setOnClickListener(new OnClickListener() {});
@Override
public void onClick(View arg0) { fetchData(); }
protected void fetchData() {
progressDialog =
ProgressDialog.show(this, "", "Doing...");
new Thread() {
public void run() {
try { Thread.sleep(800);} catch (InterruptedException e) { } messageHandler.sendEmptyMessage(0); }
}.start();
} |
----
get Name class strong intent:
intent.getComponent().getClassName()
Beyond Compare
-Background and text, back ground
Textcolor
: #ffff, textsize 18dp, textstyle bold
Date:
Calendar c = Calendar.getInstance();
int day =
c.get(Calendar.DATE) ;
read
write file:
File root = new
File(Environment.getExternalStorageDirectory(), "Notes");
if(!root.exists()){
root.mkdirs();
}
File mFile = new File(root,
path);
FileWriter mFileWriter = new
FileWriter(mFile);
BufferedWriter buff = new
BufferedWriter(mFileWriter);
buff.append(text);
buff.newLine();
buff.close();
|
File root = new
File(Environment.getExternalStorageDirectory(), "Notes");
if(!root.exists()){
root.mkdirs();
}
File mFile = new File(root,
filename);
StringBuilder sText = new StringBuilder();
BufferedReader br = new BufferedReader(new
FileReader(mFile));
String line;
while((line =
br.readLine())!= null){
sText.append(line);
}
return
sText.toString();
|
Export
ko co SVN: team -> export
XML
design:
Set
textsize : 12 sp
Set
margin : 12dp
Background
– mau nen trong suot : android:background="#a0000000"
Background-mau
nen den/trang : android:background="@android:drawable/alert_light_frame"/android:background="@android:drawable/alert_dark_frame"
-
To call again click of button : call function:
performClick();
Mang:
View...
buttons ====== ArrayList<View>buttons;
String…
arrString ====== ArrayList<String>arrString;
Trong ham
static, cac doi so trong ay phai static, co cach nao truyen ham thuong vao
static.
public
class ResourceManager {
private static final String TAG
= "ResourceManager";
private static ResourceManager
instance = null;
Context context;
static ResourceManager
createInstance(Context context){
instance = new
ResourceManager(context);
return instance;
}
public static ResourceManager
getInstance(){
return instance;
}
private ResourceManager(Context
context){
this.context =
context;;
}
}
|
-
Get
String from string.xml:
context.getString(R.string.GA);
\
-
Lay
color trong android mac dinh:
android:textColor="@android:color/white"
// chan hien thi ban phim vao edittext;
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
hide ban phim ao tren edittext khi click vao button
InputMethodManager inputMethodManager =
(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
-
Alert Dialog
Builder
private void saveLyric() {
AlertDialog.Builder lAlertDialog
= new AlertDialog.Builder(
NewActivity2.this);
lAlertDialog.setTitle("Save action");
lAlertDialog.setCancelable(true);
lAlertDialog.setPositiveButton("OK",
new
DialogInterface.OnClickListener() {
public void
onClick(DialogInterface dialogInterface, int i) {
Toast.makeText(getApplicationContext(),
"Selected item: " + i, Toast.LENGTH_SHORT)
.show();
}
});
lAlertDialog.setNegativeButton("Cancel",
new DialogInterface.OnClickListener()
{
public void
onClick(DialogInterface dialogInterface, int i) {
}
});
lAlertDialog.setIcon(R.drawable.save_icon);
lAlertDialog.show();
}
|
tabHost nam duoi 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:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/header_gradient"
/>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/header_gradient"
/>
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
/>
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/header_gradient"
/>
</LinearLayout>
</TabHost>
|
Alert Builder
new AlertDialog.Builder(mContext)
.setTitle("error")
.setMessage("システムエラー")
.setNeutralButton("close",
new
DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface
dialog, int which) {
// 作りかけ(onCreate()が始まった)の設定画面を消せないかな?
mDLFileNGFlag = true;
finish();
}
})
.show();
|
Không có nhận xét nào:
Đăng nhận xét