The Activity Code:
@ Override
public boolean onContextItemSelected (MenuItem menuItem) {
int menuItemId = menuItem.getItemId ();
if (menuItemId == START_VIDEO) {/ / start the video, then change the UI display
ItemString videoUri = curMsg.getVideoUri ();
if (videoUri.startsWith (Environment.getExternalStorageDirectory (). getAbsolutePath ())) {/ / local video
. msgArr.get (curItem) setDownloadVideo (1);
adapter.notifyDataSetChanged ();
}
} Else if (menuItemId == DELETE_MSG) {/ / delete the specified Item, update ListView show
/ / TODO Auto-generated method stub
msgArr.remove (curMsg);
adapter.notifyDataSetChanged ();
}
return super.onContextItemSelected (menuItem);
}
Adapter code:
@ Override
public View getView (int position, View convertView, ViewGroup parent) {
MessageData msg = dataArray.get (position);
if (msg.getDownloadVideo () == 1) {
convertView = inflater.inflate (R.layout.video_download, null);
SurfaceView surfaceView = (SurfaceView) convertView.findViewById (R.id.surface_view);
ImageView imageView = (ImageView) convertView.findViewById (R.id.start_video_btn);
imageView.setOnClickListener (startVideoOnClickListener);
Bitmap bitmap = UiUtil.createVideoThumbnail (ConstantValues.videoRecordPath);
if (bitmap! = null) {
surfaceView.setBackgroundDrawable (new BitmapDrawable (bitmap));
}
} Else {
convertView = inflater.inflate (judgeMsgOrigin (msg.getStrUserId ()) == MessageData.FROM? from
: To, null);
/ / Avatar
ImageView itemImage = (ImageView) convertView
. FindViewById (R.id.itemImage);
/ / actual projects, definitely get msg object based on the User object, then get the image of the address to be loaded; itemImage.setBackgroundResource (Integer.parseInt (msg.getImgsrc ()))/ / I'm here to be lazy, using a drawable in the picture, and put into the imgSrc in
resourceId/ / Name
TextView itemName = (TextView) convertView.findViewById (R.id.itemName);
itemName.setText (msg.getStrNickName ());
/ / Time
TextView itemDate = (TextView) convertView.findViewById (R.id.itemDate);
itemDate.setText (msg.getMsgtime ());
/ / Message
TextView itemMsg = (TextView) convertView.findViewById (R.id.itemMsg);
itemMsg.setText (msg.getMsgContent ());
}
return convertView;
}
The problem now is that dynamically change the layout inside Item, the phone will be a black screen, you must hand tap to appear. Effect appears indeed want. But why has the black screen.
Deletes the specified Item, no problem. Normal.
Reply:
convertview is the old view that has created. / / android is this introduction.
I suggest you add determine if converview == null, it created. If converview is not null, it wants to replace the contents inside.
You can try
Reply:
This is the beginning of showing
This is the user to click to start the video (and then UI change)
Then would have been black, you must manually click of the screen, this effect will appear.
Help, why has a black screen.
Reply:
I'm such a replacement is replaced Layout. And converview is not Null should be irrelevant. I have to replace, if not null
Reply:
Offer to replace the Item Layout ideas can, ah, Chousi me
Reply:
There is no log, click on it to see what, to whom handled?
Reply:
http://hi.baidu.com/yiyudemei/item/76ac4456b3994e9b09be1787
Reply:
android: cacheColorHint = "# 00000000"
Reply:
This has been in the xml file to listview set
My xml file
android: orientation = "vertical"
android: layout_width = "fill_parent"
android: layout_height = "fill_parent"
android: background = "@ drawable / msg_history_bg"
android: id = "@ + id / msg_history_layout"
>android: layout_width = "fill_parent"
android: layout_height = "fill_parent"
android: cacheColorHint = "# 00000000"
android: listSelector = "@ drawable / list_selector"
android: fadingEdge = "none"
android: scrollbars = "none">
Reply:
log can not see, is called adapter.notifyDataSetChanged ();
Just tried it and found a second point on the video, Item will directly add one out. Third, too,
Is the first time, will be black.
Reply:
android: cacheColorHint = "# 00000000"
android: scrollingCache = "false"
Reply:
Regardless
Or it looks like on the first black, has also been black. The second point to start the video again, all right
Reply:
Will the getView, there is a case to return null
Reply:
Well this really is not what I want ah pro
No comments:
Post a Comment