========================================
activity_main.xml
========================================
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="傳送到..."
android:id="@+id/to"
/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="輸入內容"
android:id="@+id/content"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="傳送"
android:id="@+id/send"
/>
</LinearLayout>
stockwfj3 發表在 痞客邦 留言(0) 人氣(503)
textView.setText(Html.fromHtml("HTML碼"));
stockwfj3 發表在 痞客邦 留言(0) 人氣(62)
<TextView
android:id="@+id/txt_all"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/txt"
android:autoLink="all"
android:layout_below="@+id/txt"
android:text="http://tw.yahoo.com" />
stockwfj3 發表在 痞客邦 留言(0) 人氣(76)
private String[] setdata(int length, String dataname) {
String[] array = new String[length];
for (int i = 0; i < length; i++) {
array[i] = dataname + ":" + i;
}
return array;
}
stockwfj3 發表在 痞客邦 留言(0) 人氣(52)
===============
MainActivity.java
===============
Fragment1 fragment1 = new Fragment1();
getSupportFragmentManager().beginTransaction()
.addToBackStack(null)
.replace(R.id.main_layout, fragment1)
.commit();
stockwfj3 發表在 痞客邦 留言(0) 人氣(995)
public String get_json_string(String urls)
{
StringBuilder sb = new StringBuilder();
try {
URL url = new URL(urls);
BufferedReader in = new BufferedReader(
new InputStreamReader(url.openStream()));
String line = in.readLine();
while(line!=null){
sb.append(line);
line = in.readLine();
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return sb.toString();
}
stockwfj3 發表在 痞客邦 留言(0) 人氣(84)
//檢查網路連線狀況
public void chkNet(){
ConnectivityManager connMgr = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
if (networkInfo != null && networkInfo.isConnected()) {
//Toast.makeText(MainActivity.this, "網路連線中", Toast.LENGTH_SHORT).show();
} else {
//處理確認按鈕的點擊事件
Toast.makeText(MainActivity.this, "網路斷線", Toast.LENGTH_SHORT).show();
}
} // end chkNet
stockwfj3 發表在 痞客邦 留言(0) 人氣(104)
例1:12小時制
new TimePickerDialog(this,myTimeSetListener,myHour, myMinute, false);
stockwfj3 發表在 痞客邦 留言(0) 人氣(97)
try {
Thread.sleep(1000); //1000為1秒
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
stockwfj3 發表在 痞客邦 留言(0) 人氣(4,160)
try {
HttpClient client = new DefaultHttpClient();
URI website = new URI("網路URL"); //指定URL
//指定POST模式
HttpPost request = new HttpPost();
stockwfj3 發表在 痞客邦 留言(0) 人氣(463)