悬浮透明框

来源:互联网 发布:简历淘宝美工工作描述 编辑:程序博客网 时间:2024/05/17 13:14

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() {@Overridepublic void onClick(View v) {mPopWin.dismiss();}});rootcategory.setOnItemClickListener(new AdapterView.OnItemClickListener() {@Overridepublic 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;}@Overridepublic int getCount() {return itemList.size();}@Overridepublic Object getItem(int position) {return itemList.get(position);}@Overridepublic long getItemId(int position) {return position;}@Overridepublic 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;}}