悬浮透明框

1.

locationAddDemo();

2.

private void locationAddDemo() {
		itemList = new ArrayList<String>();
		itemList.add("图片动态");
		itemList.add("视频动态");

		RelativeLayout locationAddDemoLayout = (RelativeLayout) LayoutInflater.from(MessageBoardMainActivity.this).inflate(R.layout.friend_adds, null);
		ListView rootcategory = (ListView) locationAddDemoLayout.findViewById(R.id.rootcategory);
		RelativeLayout popupLayout = (RelativeLayout) locationAddDemoLayout.findViewById(R.id.popup_layout);

		MessageBoardMainAddsListAdapter messageBoardMainAddsListAdapter = new MessageBoardMainAddsListAdapter(MessageBoardMainActivity.this,itemList);
		rootcategory.setAdapter(messageBoardMainAddsListAdapter);

		mPopWin = new PopupWindow(locationAddDemoLayout, RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT, true);
		mPopWin.setBackgroundDrawable(new BitmapDrawable());
		mPopWin.showAtLocation(messageboard_main_play, Gravity.RIGHT, 20, -620);
		mPopWin.update();

		popupLayout.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				mPopWin.dismiss();
			}
		});

		rootcategory.setOnItemClickListener(new AdapterView.OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
				if(position==0){
					Intent i = new Intent(MessageBoardMainActivity.this,MeDynamicAddActivity.class);
					startActivityForResult(i, 1);
				}else if(position==1){

				}
				mPopWin.dismiss();
			}
		});
	}

3.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/popup_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/transparent"
    >

    <RelativeLayout
        android:layout_width="130dp"
        android:layout_height="wrap_content"
        android:background="@color/transparent"
        android:layout_centerVertical="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true">

        <ListView
            android:id="@+id/rootcategory"
            android:layout_width="130dp"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:background="#b0454545"
            android:divider="@null"
            android:scrollbars="vertical" />
    </RelativeLayout>

</RelativeLayout>

4.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/categoryadapter_layout"
    android:layout_width="fill_parent"
    android:layout_height="40dp" >

    <ImageView
        android:id="@+id/f_imageView"
        android:layout_width="20dp"
        android:layout_height="20dp"
        android:layout_alignParentLeft="true"
        android:layout_marginBottom="5dp"
        android:layout_marginLeft="15dp"
        android:layout_marginTop="5dp"
        android:layout_centerVertical="true"
        android:contentDescription="@string/sub_image" />

    <TextView
        android:id="@+id/f_name"
        android:layout_width="wrap_content"
        android:layout_height="40dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="15dp"
        android:layout_centerVertical="true"
        android:layout_toRightOf="@+id/f_imageView"
        android:drawablePadding="3dp"
        android:gravity="center_vertical"
        android:textColor="@color/white"
        android:textSize="15sp" />

    <View
        android:id="@+id/f_view"
        android:layout_width="fill_parent"
        android:layout_height="0.1dp"
        android:layout_marginLeft="15dp"
        android:layout_marginRight="15dp"
        android:layout_alignParentBottom="true"
        android:background="@color/white" />

</RelativeLayout>
6.
public class MessageBoardMainAddsListAdapter extends BaseAdapter {
	private Context context;
	private ArrayList<String> itemList;

	public MessageBoardMainAddsListAdapter(Context context, List<String> itemList) {
		this.context = context;
		this.itemList = (ArrayList<String>) itemList;
	}

	@Override
	public int getCount() {
		return itemList.size();
	}

	@Override
	public Object getItem(int position) {
		return itemList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder viewHolder = null;
		if (convertView == null) {
			viewHolder = new ViewHolder();
			convertView = LayoutInflater.from(context).inflate(R.layout.friend_adds_item, null);
			viewHolder.mNameTextView = (TextView) convertView.findViewById(R.id.f_name);
			viewHolder.ImageView01 = (ImageView) convertView.findViewById(R.id.f_imageView);
			viewHolder.f_view = convertView.findViewById(R.id.f_view);
//			viewHolder.categoryadapter_layout = (RelativeLayout) convertView.findViewById(R.id.categoryadapter_layout);
			convertView.setTag(viewHolder);
		} else {
			viewHolder = (ViewHolder) convertView.getTag();
		}
		String mainName = itemList.get(position);
		viewHolder.mNameTextView.setText(mainName);

		if (position == 0) {
			viewHolder.ImageView01.setBackgroundResource(R.drawable.image_add);
			viewHolder.f_view.setVisibility(View.VISIBLE);
		} else if (position == 1) {
			viewHolder.ImageView01.setBackgroundResource(R.drawable.vedio_add);
			viewHolder.f_view.setVisibility(View.INVISIBLE);
		}

		return convertView;
	}

	class ViewHolder {
		public TextView mNameTextView;
		public ImageView ImageView01;
//		public RelativeLayout categoryadapter_layout;
		public View f_view;
	}

}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值