- Oct 09 Thu 2014 14:27
-
Android中讓TextView跟隨EditText同步變更
- Oct 08 Wed 2014 14:32
-
RelativeLayout
- Oct 03 Fri 2014 16:34
-
利用setTag傳遞參數
當使用Fragment時,如果想要在不同Fragment間傳遞資料,
可以使用setTag方法,範例程式(假設有兩個頁籤fragment1, fragment2;在fragment1中傳給fragment2)如下:
View v;
可以使用setTag方法,範例程式(假設有兩個頁籤fragment1, fragment2;在fragment1中傳給fragment2)如下:
View v;
- Oct 02 Thu 2014 15:50
-
在Fragment中使用具有Scrollbar的TextView
首先,在Fragment (本例中叫fragment2) 中以xml配置一個LinearLayout,在本例子中id設為f2_layout
覆蓋onCreateView
v = inflater.inflate(R.layout.frament2, container, false);
覆蓋onCreateView
v = inflater.inflate(R.layout.frament2, container, false);
- Oct 01 Wed 2014 13:51
-
在Fragment中變更TextView或EditText
在Fragment中要使用TextView或EditText時,先要在Fragment頁面中佈置一個LinearLayout,再使用addView方法,參考程式碼如下:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Sep 29 Mon 2014 15:02
-
Android上使用SD卡
- Sep 29 Mon 2014 14:29
-
在Fragment頁中以程式碼切換到其他頁
在Fragment頁中要以程式碼切換到其他頁時,由於許多的物件都是屬於Activity的方法,
而Fragment本身並未繼承Activity,所以在取得這些相關物件時,要在前面加上getActivity().才能進行。
而Fragment本身並未繼承Activity,所以在取得這些相關物件時,要在前面加上getActivity().才能進行。
- Sep 27 Sat 2014 20:46
-
在Android中使用Diaglog
AlertDialog dialog = new AlertDialog.Builder(getActivity()).create();
dialog.setTitle("Title");
dialog.setTitle("Title");
- Sep 23 Tue 2014 17:58
-
在子標籤頁Fragment中使用ListView
- Sep 23 Tue 2014 16:53
-
在Android程式設計時,使用Resource中的字串
範例如下:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<stringname="hello">Hello!</string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<stringname="hello">Hello!</string>
</resources>
- Sep 23 Tue 2014 16:37
-
在多標籤頁中使用findViewById
在Android的程式設計中,多頁籤的設計十分常見,但如果在子頁籤中想要以findViewById()來使用View之類的控件時,
會因為子頁籤Fragment不支援而產生錯誤,此時就要改用
this.getView().findViewById()來達到目的
會因為子頁籤Fragment不支援而產生錯誤,此時就要改用
this.getView().findViewById()來達到目的