Perhaps your code should start with:
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_radio); }
You specify onClick in xml
android:onClick="playPauseMusic"
So the method works, you have an internal onClicks. If these are some submissions.
You need to initialize and get it from xml in code, for ex -
If you have an ImageButton in xml whose identifier is "playPause"
ImageButton playPause; //Declare it here if you wanna use it in all other places in the class or outside of your class @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_radio); playPause = (ImageButton)findViewById(R.id.playPause); playPause.setOnClickListener(new View.OnClickListener(){ public void onClick(View view) { //OnCLick Stuff } }); }
In your case, you have the onClick attribute in xml and other onCLick code. You use it.
johnrao07
source share