onClickListener does not work in fragment

I think problem is here in your code public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ….. …. //problem is here below line return inflater.inflate(R.layout.input_fgmt, container, false); } return your already inflated view public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View inputFragmentView = inflater.inflate(R.layout.input_fgmt, container, false); ….. …. return inputFragmentView; }

Best way to implement View.OnClickListener in Android

First, there is no best practice defined by Android regarding registering click listeners. It totally depends on your use case. Implementing the View.OnClickListener interface to Activity is the way to go. As Android strongly recommends interface implementation over and over again whether it is an Activity or Fragment. Now as you described : public class … Read more

Android – setOnClickListener vs OnClickListener vs View.OnClickListener

Imagine that we have 3 buttons for example public class MainActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Capture our button from layout Button button = (Button)findViewById(R.id.corky); Button button2 = (Button)findViewById(R.id.corky2); Button button3 = (Button)findViewById(R.id.corky3); // Register the onClick listener with the implementation above button.setOnClickListener(mCorkyListener); button2.setOnClickListener(mCorkyListener); button3.setOnClickListener(mCorkyListener); } // Create … Read more

OnClickListener not responding

When using a DrawerLayout, there should be only one main content View, with the drawer View – in this case, your ListView – listed after it. Using a DrawerLayout in any other way will result in incorrect, unpredictable behavior, often preventing normal interaction with other layout elements. A tutorial with links to a sample and … Read more

clickable area of image

I have 2 solutions for your requirement.in both,the whole image stays clickable but you can get information about clicked area. Solution 1: you can mask the image and get the pixel color of that underneath image.so ultimately you can come to know which area has been clicked. here,whenever clicked occurs,you can check the pixel color … Read more