当前位置:  编程技术>移动开发
本页文章导读:
    ▪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详情

主要代码:
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;
     }
}

    
最新技术文章:
▪Android开发之登录验证实例教程
▪Android开发之注册登录方法示例
▪Android获取手机SIM卡运营商信息的方法
▪Android实现将已发送的短信写入短信数据库的...
▪Android发送短信功能代码
▪Android根据电话号码获得联系人头像实例代码
▪Android中GPS定位的用法实例
▪Android实现退出时关闭所有Activity的方法
▪Android实现文件的分割和组装
▪Android录音应用实例教程
▪Android双击返回键退出程序的实现方法
▪Android实现侦听电池状态显示、电量及充电动...
▪Android获取当前已连接的wifi信号强度的方法
▪Android实现动态显示或隐藏密码输入框的内容
▪根据USER-AGENT判断手机类型并跳转到相应的app...
▪Android Touch事件分发过程详解
▪Android中实现为TextView添加多个可点击的文本
▪Android程序设计之AIDL实例详解
▪Android显式启动与隐式启动Activity的区别介绍
▪Android按钮单击事件的四种常用写法总结
▪Android消息处理机制Looper和Handler详解
▪Android实现Back功能代码片段总结
▪Android实用的代码片段 常用代码总结
▪Android实现弹出键盘的方法
▪Android中通过view方式获取当前Activity的屏幕截...
▪Android提高之自定义Menu(TabMenu)实现方法
▪Android提高之多方向抽屉实现方法
▪Android提高之MediaPlayer播放网络音频的实现方法...
▪Android提高之MediaPlayer播放网络视频的实现方法...
▪Android提高之手游转电视游戏的模拟操控
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3