I am going through a very weird problem of Button not responding to click events. I have a dialog box that is displayed and then when the user clicks on the positive button in the dialog, it opens up a layout with video , textbox and buttons on it. Whenever I click the button on the layout, it is unresponsive! Please help.
Layout file :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_root"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/roundedcorners"
android:orientation="vertical"
android:padding="0dp" >
<LinearLayout
android:id="@+id/video_panel"
android:layout_width="match_parent"
android:layout_height="175dp"
android:layout_above="@+id/bottom_panel"
android:layout_alignParentTop="true"
android:layout_gravity="top"
android:gravity="top"
android:orientation="vertical" >
</LinearLayout>
<RelativeLayout
android:id="@+id/bottom_panel"
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_gravity="bottom"
android:background="@color/milky_white"
android:gravity="bottom"
android:orientation="vertical" >
<TextView
android:id="@+id/agentname"
android:layout_width="match_parent"
android:layout_height="35dp"
android:background="@color/video_username"
android:layout_alignParentTop="true"
android:textStyle="bold"
android:text="name"/>
<Button
android:id="@+id/disconn"
android:layout_width="510dp"
android:layout_height="37dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:clickable="true"
android:text="@string/disconnect" />
</RelativeLayout>
</RelativeLayout>
The code for the onClick is given as :
alertVideoChatBuilder.setMessage(message);
alertVideoChatBuilder.setPositiveButton("Answer", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
StatusJson sj = new StatusJson("User accepted.",1);
outCmd.sendJsonCommand(getNodeId(), "videoChatStatus", sj);
handler.post(new Runnable() {
@Override
public void run() {
try {
pc = pcf.createPeerConnection(iceServers, pcConstraints, new PCObserver(nodeId));
} catch (UnsupportedOnThisDeviceException e) {
Log.e("MeshAgent", "Video chat not supported");
return;
}
MediaConstraints audio = new MediaConstraints();
audio.mandatory.add(new KeyValuePair("googEchoCancellation", "true"));
audio.mandatory.add(new KeyValuePair("googAutoGainControl", "true"));
//audio.mandatory.add(new KeyValuePair("noiseSuppression", "false"));
MediaStream ms = pcf.createLocalMediaStream("device");
AudioSource as = pcf.createAudioSource(audio);
AudioTrack at = pcf.createAudioTrack("devicea0",as);
ms.addTrack(at);
pc.addStream(ms, audio);
videoView = new VideoStreamsView(context, R.drawable.tech_mute, R.drawable.tech_connect);
LayoutInflater li = LayoutInflater.from(context);
outerVideoView = (RelativeLayout) li.inflate(R.layout.chat_float, null);
LinearLayout vView = (LinearLayout) outerVideoView.findViewById(R.id.video_panel);
TextView agent_name = (TextView) outerVideoView.findViewById(R.id.agentname);
agent_name.setText(name);
//RelativeLayout bottomView = (RelativeLayout) outerVideoView.findViewById(R.id.bottom_panel);
Button discon_but = (Button) outerVideoView.findViewById(R.id.disconn);
discon_but.setClickable(true);
discon_but.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
//System.out.println("mesh: button clicked disconnect!!");
Toast.makeText(context, "Video Connection disconnected", Toast.LENGTH_LONG).show();
outCmd.sendJsonCommand(getNodeId(), "videoChatStatus", new StatusJson("User disconnected the call.",1));
coord.disconnect();
}
});
vView.addView(videoView);
wm.addView(outerVideoView, params);