当前位置: 编程技术>移动开发
本页文章导读:
▪PopupWindow兑现弹出窗口 PopupWindow实现弹出窗口
点击ListView的每一个item,将弹出窗口显示item详情主要代码:private void openPopupwin() {
LayoutInflater mLayoutInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
ViewGroup roo.........
▪ 第九节(Activity格局初步二-嵌套布局) 第九节(Activity布局初步二--嵌套布局)
<?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"
and.........
▪ 基准的base32编码和解码 标准的base32编码和解码
public class Base32 { private static final String base32Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"; private static final int[] base32Lookup = { 0xFF, 0xFF, 0x1A,.........
[1]PopupWindow兑现弹出窗口
来源: 互联网 发布时间: 2014-02-18
PopupWindow实现弹出窗口
点击ListView的每一个item,将弹出窗口显示item详情
主要代码:
弹出窗口布局文件:
popup_enter.xml
popup_exit.xml
popup_corner.xml
APIDEMo里面的View下面有很多这方面的例子
点击ListView的每一个item,将弹出窗口显示item详情
主要代码:
private void openPopupwin() { LayoutInflater mLayoutInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); ViewGroup rootView = (ViewGroup) mLayoutInflater.inflate(R.layout.person_info_pop, null, true); TextView person_popup_name = (TextView)rootView.findViewById(R.id.person_popup_name); TextView person_popup_realName = (TextView)rootView.findViewById(R.id.person_popup_realName); TextView person_popup_age = (TextView)rootView.findViewById(R.id.person_popup_age); TextView person_popup_birthday = (TextView)rootView.findViewById(R.id.person_popup_birthday); TextView person_popup_phone = (TextView)rootView.findViewById(R.id.person_popup_phone); TextView person_popup_deptId = (TextView)rootView.findViewById(R.id.person_popup_deptId); Button btn_popup_close = (Button)rootView.findViewById(R.id.btn_popup_close); ImageView person_popup_head = (ImageView)rootView.findViewById(R.id.person_popup_head); try { person_popup_name.setText(selectedperson.getString("name")); person_popup_realName.setText(selectedperson.getString("realName")); person_popup_age.setText(selectedperson.getString("age")); person_popup_birthday.setText(selectedperson.getString("birthday")); person_popup_phone.setText("13880012450");//还未添加字段 person_popup_deptId.setText("产品事业部"); person_popup_head.setBackgroundDrawable(ImageUtil.geRoundDrawableFromUrl(HttpUtil.BASE_URL+selectedperson.getString("headPhotoPath"), 10)); } catch (JSONException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } popupWindow = new PopupWindow(rootView, LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT, true); popupWindow.setBackgroundDrawable(new BitmapDrawable()); popupWindow.setAnimationStyle(R.style.PopupAnimation); popupWindow.showAtLocation(root, Gravity.CENTER | Gravity.CENTER, 0, 0); popupWindow.update(); btn_popup_close.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popupWindow.dismiss(); } }); }
弹出窗口布局文件:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:gravity="center" android:layout_height="wrap_content" android:layout_gravity="center" android:padding="5.0dip" android:layout_margin="5.0dip" android:background="@drawable/popup_corner"> <RelativeLayout android:id="@+id/popup_top_bar" android:layout_alignParentTop="true" android:layout_width="fill_parent" android:layout_height="wrap_content"> <TextView android:text="用户详细信息" android:textColor="#760606" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="16.0sp" android:layout_alignParentLeft="true"/> <Button android:id="@+id/btn_popup_close" android:background="@drawable/popup_close" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true"/> </RelativeLayout> <ImageView android:id="@+id/person_popup_head" android:scaleType="fitXY" android:layout_marginTop="5.0dip" android:layout_below="@id/popup_top_bar" android:layout_width="120.0dip" android:layout_height="120.0dip"/> <TableLayout android:id="@+id/person_form" android:layout_marginLeft="2.0dip" android:layout_marginTop="5.0dip" android:layout_toRightOf="@id/person_popup_head" android:layout_below="@id/popup_top_bar" android:layout_width="wrap_content" android:layout_height="wrap_content"> <TableRow > <TextView android:layout_width="60.0dip" android:gravity="right" android:textColor="#074f92" android:layout_height="wrap_content" android:text="账号:"/> <TextView android:id="@+id/person_popup_name" android:textColor="#074f92" android:layout_marginLeft="15.0dip" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </TableRow> <TableRow > <TextView android:layout_width="60.0dip" android:gravity="right" android:textColor="#074f92" android:layout_height="wrap_content" android:text="姓名:"/> <TextView android:id="@+id/person_popup_realName" android:textColor="#074f92" android:layout_marginLeft="15.0dip" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </TableRow> <TableRow > <TextView android:layout_width="60.0dip" android:gravity="right" android:textColor="#074f92" android:layout_height="wrap_content" android:text="年龄:"/> <TextView android:id="@+id/person_popup_age" android:textColor="#074f92" android:layout_marginLeft="15.0dip" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </TableRow> <TableRow > <TextView android:layout_width="60.0dip" android:gravity="right" android:textColor="#074f92" android:layout_height="wrap_content" android:text="生日:"/> <TextView android:id="@+id/person_popup_birthday" android:textColor="#074f92" android:layout_marginLeft="15.0dip" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </TableRow> <TableRow > <TextView android:layout_width="60.0dip" android:gravity="right" android:textColor="#074f92" android:layout_height="wrap_content" android:text="电话号码:"/> <TextView android:id="@+id/person_popup_phone" android:textColor="#074f92" android:layout_marginLeft="15.0dip" android:layout_width="wrap_content" android:layout_height="wrap_content" android:autoLink="phone"/> </TableRow> <TableRow > <TextView android:layout_width="60.0dip" android:gravity="right" android:textColor="#074f92" android:layout_height="wrap_content" android:text="部门:"/> <TextView android:id="@+id/person_popup_deptId" android:textColor="#074f92" android:layout_marginLeft="15.0dip" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </TableRow> </TableLayout> </RelativeLayout>
popup_enter.xml
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <scale android:fromXScale="0.6" android:toXScale="1.0" android:fromYScale="0.6" android:toYScale="1.0" android:pivotX="50%" android:pivotY="50%" android:duration="1000" /> <alpha android:interpolator="@android:anim/decelerate_interpolator" android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="1000" /> </set>
popup_exit.xml
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <scale android:fromXScale="1.0" android:toXScale="0.5" android:fromYScale="1.0" android:toYScale="0.5" android:pivotX="50%" android:pivotY="50%" android:duration="500" /> <alpha android:interpolator="@android:anim/accelerate_interpolator" android:fromAlpha="1.0" android:toAlpha="0.0" android:duration="500" /> </set>
popup_corner.xml
<?xml version="1.0" encoding="UTF-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:startColor="#cbeafe" android:endColor="#ffffff" android:angle="90" /> <!-- <stroke android:dashWidth="2dp" android:dashGap="2dp" android:width="2dp" android:color="#FF00ff00"/>--> <!--描边--> <corners android:bottomRightRadius="5dp" android:bottomLeftRadius="5dp" android:topLeftRadius="5dp" android:topRightRadius="5dp" /> <!--设置圆角--> </shape>
1 楼
zhenzxie
2011-10-10
请问,,那些xml中<set><shape>等在哪里可以查阅到。。我是新学习android的,还不太了解这方面。。
2 楼
helloandroid
2011-10-11
zhenzxie 写道
请问,,那些xml中<set><shape>等在哪里可以查阅到。。我是新学习android的,还不太了解这方面。。
APIDEMo里面的View下面有很多这方面的例子
3 楼
zhenzxie
2011-10-11
谢谢。。有空去研究一下。
[2] 第九节(Activity格局初步二-嵌套布局)
来源: 互联网 发布时间: 2014-02-18
第九节(Activity布局初步二--嵌套布局)
<?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" > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" > <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="one" android:layout_weight="1" /> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="two" android:layout_weight="1" /> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="three" android:layout_weight="1" /> </LinearLayout> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" > <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="one" android:layout_weight="1" /> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="two" android:layout_weight="1" /> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="three" android:layout_weight="1" /> </LinearLayout> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" > <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:stretchColumns="0" > <!-- android:stretchColumns="0"如果不能撑满窗口,拉伸第0列填满窗口 --> <TableRow> <TextView android:text="column1" android:padding="5dip" android:background="#aa0000" /> <TextView android:text="column2" android:padding="5dip" android:background="#0000aa" android:layout_gravity="center_vertical" /> <TextView android:text="column3" android:padding="5dip" android:background="#00aa00" /> </TableRow> <TableRow> <TextView android:text="column1" android:padding="5dip" /> <TextView android:text="column2" android:padding="5dip" /> <TextView android:text="column3" android:padding="5dip" /> </TableRow> </TableLayout> </LinearLayout> </LinearLayout>
android:layout_weight="1" 可叫 “权重”
此属性指定该标签在一个布局当中占x/y的空间
[3] 基准的base32编码和解码
来源: 互联网 发布时间: 2014-02-18
标准的base32编码和解码
public class Base32 {
private static final String base32Chars =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
private static final int[] base32Lookup = {
0xFF, 0xFF, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, // '0', '1', '2', '3', '4', '5', '6', '7'
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // '8', '9', ':', ';', '<', '=', '>', '?'
0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, // '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G'
0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, // 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O'
0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, // 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W'
0x17, 0x18, 0x19, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 'X', 'Y', 'Z', '[', '\', ']', '^', '_'
0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, // '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g'
0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, // 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'
0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, // 'p', 'q', 'r', 's', 't', 'u', 'v', 'w'
0x17, 0x18, 0x19, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF // 'x', 'y', 'z', '{', '|', '}', '~', 'DEL'
};
public static String encode(
final byte[] bytes) {
int i = 0, index = 0, digit = 0;
int currByte, nextByte;
StringBuffer base32 = new StringBuffer((bytes.length + 7) * 8 / 5);
while (i < bytes.length) {
currByte = (bytes[i] >= 0) ? bytes[i] : (bytes[i] + 256); // unsign
/* Is the current digit going to span a byte boundary? */
if (index > 3) {
if ((i + 1) < bytes.length) {
nextByte = (bytes[i + 1] >= 0) ? bytes[i + 1] : (bytes[i + 1] + 256);
} else {
nextByte = 0;
}
digit = currByte & (0xFF >> index);
index = (index + 5) % 8;
digit <<= index;
digit |= nextByte >> (8 - index);
i++;
} else {
digit = (currByte >> (8 - (index + 5))) & 0x1F;
index = (index + 5) % 8;
if (index == 0) {
i++;
}
}
base32.append(base32Chars.charAt(digit));
}
return base32.toString();
}
public static byte[] decode(
final String base32) {
int i, index, lookup, offset, digit;
byte[] bytes = new byte[base32.length() * 5 / 8];
for (i = 0, index = 0, offset = 0; i < base32.length(); i++) {
lookup = base32.charAt(i) - '0';
/* Skip chars outside the lookup table */
if (lookup < 0 || lookup >= base32Lookup.length) {
continue;
}
digit = base32Lookup[lookup];
/* If this digit is not in the table, ignore it */
if (digit == 0xFF) {
continue;
}
if (index <= 3) {
index = (index + 5) % 8;
if (index == 0) {
bytes[offset] |= digit;
offset++;
if (offset >= bytes.length) {
break;
}
} else {
bytes[offset] |= digit << (8 - index);
}
} else {
index = (index + 5) % 8;
bytes[offset] |= (digit >>> index);
offset++;
if (offset >= bytes.length) {
break;
}
bytes[offset] |= digit << (8 - index);
}
}
return bytes;
}
}
public class Base32 {
private static final String base32Chars =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
private static final int[] base32Lookup = {
0xFF, 0xFF, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, // '0', '1', '2', '3', '4', '5', '6', '7'
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // '8', '9', ':', ';', '<', '=', '>', '?'
0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, // '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G'
0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, // 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O'
0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, // 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W'
0x17, 0x18, 0x19, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 'X', 'Y', 'Z', '[', '\', ']', '^', '_'
0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, // '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g'
0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, // 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'
0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, // 'p', 'q', 'r', 's', 't', 'u', 'v', 'w'
0x17, 0x18, 0x19, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF // 'x', 'y', 'z', '{', '|', '}', '~', 'DEL'
};
public static String encode(
final byte[] bytes) {
int i = 0, index = 0, digit = 0;
int currByte, nextByte;
StringBuffer base32 = new StringBuffer((bytes.length + 7) * 8 / 5);
while (i < bytes.length) {
currByte = (bytes[i] >= 0) ? bytes[i] : (bytes[i] + 256); // unsign
/* Is the current digit going to span a byte boundary? */
if (index > 3) {
if ((i + 1) < bytes.length) {
nextByte = (bytes[i + 1] >= 0) ? bytes[i + 1] : (bytes[i + 1] + 256);
} else {
nextByte = 0;
}
digit = currByte & (0xFF >> index);
index = (index + 5) % 8;
digit <<= index;
digit |= nextByte >> (8 - index);
i++;
} else {
digit = (currByte >> (8 - (index + 5))) & 0x1F;
index = (index + 5) % 8;
if (index == 0) {
i++;
}
}
base32.append(base32Chars.charAt(digit));
}
return base32.toString();
}
public static byte[] decode(
final String base32) {
int i, index, lookup, offset, digit;
byte[] bytes = new byte[base32.length() * 5 / 8];
for (i = 0, index = 0, offset = 0; i < base32.length(); i++) {
lookup = base32.charAt(i) - '0';
/* Skip chars outside the lookup table */
if (lookup < 0 || lookup >= base32Lookup.length) {
continue;
}
digit = base32Lookup[lookup];
/* If this digit is not in the table, ignore it */
if (digit == 0xFF) {
continue;
}
if (index <= 3) {
index = (index + 5) % 8;
if (index == 0) {
bytes[offset] |= digit;
offset++;
if (offset >= bytes.length) {
break;
}
} else {
bytes[offset] |= digit << (8 - index);
}
} else {
index = (index + 5) % 8;
bytes[offset] |= (digit >>> index);
offset++;
if (offset >= bytes.length) {
break;
}
bytes[offset] |= digit << (8 - index);
}
}
return bytes;
}
}
最新技术文章: