androidfadingedge
A. android 代碼中設置控制項的垂直居中和兩個控制項之間的距離。
首先是垂直居中,下面有朋友已經回答了,而控制項和控制項之間的距離設置是設置margin
B. android ListView中有某部分要點擊效果,此點擊效果是用selector實現,但在ListView中點擊其他部分也會有效
tvFileNameAndSize.setText(attachFile.getFileName() + "(" + attachFile.getSize() + "K)");/*將文件名與文件大小添加到顯示里*/
v.setTag(attachFile);/*將文件保存到控制項里*/
ImageView ivDelete = (ImageView) v.findViewById(R.id.iv_iccfa_del);
ivDelete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
View parent = (View) v.getParent();/*得到焦點*/
AttachFile file = (AttachFile) parent.getTag();/*將導入到這個位置的文件導出來*/
mFiles.remove(file);/*從自己的集合里移除它*/
mLlAttachFile.removeView(parent);/*從控制項里將這個焦點所對應的內容刪除*/
}
});
mLlAttachFile.addView(v);
ListView顯示的格式是一個TextView加上一個ImageView,這個就是點擊那個ImageView時刪除這一條記錄的部分代碼,
C. android 怎麼連接藍牙設備
先展示代碼結構
步驟閱讀
2
連接藍牙類
類名:MainActivity(有點偷懶,沒有起表意的類名。)
步驟閱讀
3
要聲明的控制項和變數等
步驟閱讀
4
在onCreate聲明控制項
步驟閱讀
5
ToogleButton設置開關狀態
聲明一個組件願意接收
IntentFilter intent = new IntentFilter();
步驟閱讀
6
BroadcastReceiver廣播接收器
步驟閱讀
步驟閱讀
7
listview點擊事件
OnItemClickListener
OnClickListener
步驟閱讀
步驟閱讀
8
藍牙連接
步驟閱讀
9
退出消耗頁面是的onDestroy()
步驟閱讀
10
布局結構圖
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.example.bluetooth_connection.MainActivity" >
<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" >
<LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:orientation="horizontal" >
<Button android:id="@+id/btnSearch" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="搜索" android:layout_weight="1" />
<Button android:id="@+id/btnExit" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="退出" android:layout_weight="1" />
<Button android:id="@+id/btnDis" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="開啟藍牙" android:layout_weight="1" /> </LinearLayout>
<LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:orientation="vertical" >
<ToggleButton android:id="@+id/tbtnSwitch" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="center_horizontal" android:textOff="關閉藍牙" android:textOn="開啟藍牙" /> </LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="0.3" android:orientation="vertical" >
<ListView android:id="@+id/lvDevices" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#f1f1f1" android:cacheColorHint="#ff333333" android:fadingEdge="none" android:scrollbars="none" > </ListView> </LinearLayout> </LinearLayout>
</RelativeLayout>
步驟閱讀
11
界面效果
步驟閱讀
12
例子如下