Source:
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_network, container,false); this.addMembersButton = (Button)v.findViewById(R.id.add_members); this.addMembersButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { addMembersButton.setEnabled(false); getConnectionService().findNewGuests(); } }); disconnect = (Button)v.findViewById(R.id.disconnect_btn); disband = (Button)v.findViewById(R.id.disband_btn); userView = (LinearLayout) v.findViewById(R.id.connected_users); updateUserView(); setDisconnectDisbandVisibility(); disconnect.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { new AlertDialog.Builder(getActivity()) .setMessage(R.string.dialog_disconnect) .setPositiveButton(R.string.disconnect, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Log.i(TAG, "Disconnecting..."); disconnect(); } }) .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }) .show(); } }); disband.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { new AlertDialog.Builder(getActivity()) .setMessage(R.string.dialog_disband) .setPositiveButton(R.string.disband, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { disband(); } }) .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }) .show(); } }); Button connect = (Button)v.findViewById(R.id.connect_btn); connect.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { getConnectionService().broadcastGuest(getActivity()); } }); return v; }

Target:
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_network, container,false); this.addMembersButton = (Button)v.findViewById(R.id.add_members); this.addMembersButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { addMembersButton.setEnabled(false); getConnectionService().findNewGuests(); } }); disconnect = (Button)v.findViewById(R.id.disconnect_btn); disband = (Button)v.findViewById(R.id.disband_btn); userView = (LinearLayout) v.findViewById(R.id.connected_users); updateUserView(); setDisconnectDisbandVisibility(); disconnect.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { new AlertDialog.Builder(getActivity()) .setMessage(R.string.dialog_disconnect) .setPositiveButton(R.string.disconnect, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Log.i(TAG, "Disconnecting..."); disconnect(); } }) .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }) .show(); } }); disband.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { new AlertDialog.Builder(getActivity()) .setMessage(R.string.dialog_disband) .setPositiveButton(R.string.disband, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { disband(); } }) .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }) .show(); } }); Button connect = (Button)v.findViewById(R.id.connect_btn); connect.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { getConnectionService().broadcastSelfAsGuest(getActivity().getApplicationContext()); } }); return v; }