View destItemView = mAdapter.getView(positionInt,null,mListView);if(null != destItemView){ ? TextView tvContent = (TextView) destItemView.findViewById(R.id.tv_chatcontent); ? RelativeLayoutrlFailHint = (RelativeLayout) destItemView.findViewById(R.id.send_mesg_fail_rl_id); ? ImageView ivFailHint = (ImageView) destItemView.findViewById(R.id.send_message_fail_iv_id); ? if(null != tvContent && (null != rlFailHint)){ ? ? ?String msgCont = tvContent.getText().toString(); ? ? ?if(content.equals(msgCont)){ ? ? ? ? rlFailHint.setVisibility(View.VISIBLE); ? ? ? ? ivFailHint.setVisibility(View.VISIBLE); ? ? ? ? Toast.makeText(ChatRoomActivity.this,"已經(jīng)設置顯示了",Toast.LENGTH_SHORT).show(); ? ? ?} ? ? ?final String p = positionStr; ? ? ?final String name = "pengming"; ? ? ?final String msg = msgCont; ? ? ?rlFailHint.setOnClickListener(new OnClickListener(){ ? ? ? ? @Override ? ? ? ? public void onClick(View v) { ? ? ? ? ? ?if(NetUtil.isNetworkAvailable(ChatRoomActivity.this)){ ? ? ? ? ? ? ? new SendMessageAsyncTask().execute(name,msg,p); ? ? ? ? ? ?}else{ ? ? ? ? ? ? ? //網(wǎng)絡不可用,不發(fā)送 ? ? ? ? ? ? ? Toast.makeText(ChatRoomActivity.this,getString(R.string.please_check_network_if_ok),Toast.LENGTH_SHORT).show(); ? ? ? ? ? ?} ? ? ? ? } ? ? ?}); ? }}下面這個是adapter的每個item對應的xml<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" ? ?xmlns:tools="http://schemas.android.com/tools" ? ?android:layout_width="fill_parent" ? ?android:layout_height="wrap_content" ? ?android:orientation="vertical" ? ?android:padding="6dp" > ? ?<LinearLayout ? ? ? ?android:layout_width="fill_parent" ? ? ? ?android:layout_height="wrap_content" ? ? ? ?android:gravity="center_horizontal" ? ? ? ?android:orientation="vertical" > ? ? ? ?<TextView ? ? ? ? ? ?android:id="@+id/tv_sendtime" ? ? ? ? ? ?android:layout_width="wrap_content" ? ? ? ? ? ?android:layout_height="wrap_content" ? ? ? ? ? ?android:background="#bfbfbf" ? ? ? ? ? ?android:padding="2dp" ? ? ? ? ? ?android:textColor="#ffffff" ? ? ? ? ? ?android:textSize="12sp" /> ? ?</LinearLayout> ? ?<RelativeLayout ? ? ? ?android:layout_width="fill_parent" ? ? ? ?android:layout_height="wrap_content" ? ? ? ?android:layout_marginTop="5dp" > ? ? ? ?<ImageView ? ? ? ? ? ?android:id="@+id/iv_userhead" ? ? ? ? ? ?android:layout_width="@dimen/chatmemmber_headpic_height" ? ? ? ? ? ?android:layout_height="@dimen/chatmemmber_headpic_height" ? ? ? ? ? ?android:layout_alignParentRight="true" ? ? ? ? ? ?android:layout_alignParentTop="true" ? ? ? ? ? ?android:focusable="false" /> ? ? ? ?<TextView ? ? ? ? ? ?android:id="@+id/tv_username" ? ? ? ? ? ?android:layout_width="wrap_content" ? ? ? ? ? ?android:layout_height="wrap_content" ? ? ? ? ? ?android:layout_toLeftOf="@id/iv_userhead" ? ? ? ? ? ?android:layout_marginRight="10dp" ? ? ? ? ? ?android:textColor="#818181" ? ? ? ? ? ?android:focusable="false" ? ? ? ? ? ?android:textSize="15sp" /> ? ? ? ?<TextView ? ? ? ? ? ?android:id="@+id/tv_chatcontent" ? ? ? ? ? ?android:layout_width="wrap_content" ? ? ? ? ? ?android:layout_height="wrap_content" ? ? ? ? ? ?android:layout_marginRight="10dp" ? ? ? ? ? ?android:layout_toLeftOf="@id/iv_userhead" ? ? ? ? ? ?android:layout_below="@+id/tv_username" ? ? ? ? ? ?android:background="@drawable/chatto_bg" ? ? ? ? ? ?android:clickable="true" ? ? ? ? ? ?android:focusable="true" ? ? ? ? ? ?android:gravity="left|center" ? ? ? ? ? ?android:lineSpacingExtra="2dp" ? ? ? ? ? ?android:minHeight="30dp" ? ? ? ? ? ?android:textColor="#ff000000" ? ? ? ? ? ?android:textSize="15sp" /> ? ? ? ? ? ?<RelativeLayout ? ? ? ? ? ? ? ?android:id="@+id/send_mesg_fail_rl_id" ? ? ? ? ? ? ? ?android:layout_width="@dimen/send_fail_hint_width" ? ? ? ? ? ? ? ?android:layout_height="@dimen/send_fail_hint_width" ? ? ? ? ? ? ? ?android:layout_toLeftOf="@+id/tv_chatcontent" ? ? ? ? ? ? ? ?android:background="@drawable/send_fail_bg" ? ? ? ? ? ? ? ?android:layout_centerVertical="true"> ? ? ? ? ? ? ? ?<ImageView ? ? ? ? ? ? ? ? ? ?android:id="@+id/send_message_fail_iv_id" ? ? ? ? ? ? ? ? ? ?android:layout_width="@dimen/logoHeight" ? ? ? ? ? ? ? ? ? ?android:layout_height="@dimen/logoHeight" ? ? ? ? ? ? ? ? ? ?android:src="@drawable/ic_warning_black_24dp" ? ? ? ? ? ? ? ? ? ?android:layout_centerHorizontal="true"/> ? ? ? ? ? ? ? ?<TextView ? ? ? ? ? ? ? ? ? ?android:id="@+id/send_mesg_fail_tv_id" ? ? ? ? ? ? ? ? ? ?android:layout_width="wrap_content" ? ? ? ? ? ? ? ? ? ?android:layout_height="wrap_content" ? ? ? ? ? ? ? ? ? ?android:text="@string/send_fail_text" ? ? ? ? ? ? ? ? ? ?android:layout_centerHorizontal="true" ? ? ? ? ? ? ? ? ? ?android:textColor="@color/buttonExitClikedColor" ? ? ? ? ? ? ? ? ? ?android:layout_below="@+id/send_message_fail_iv_id"/> ? ? ? ? ? ?</RelativeLayout> ? ?</RelativeLayout></LinearLayout>
使用rlFailHint.setVisibility(View.VISIBLE) 設置相對布局的可見性 失效,不顯示
qq_如朝日似暮月_0
2015-09-17 20:43:06