Tag Archives: setonclicklistener

1 views

Create RadioButton RadioGroup dynamically – Android sample

public class MainActivity extends Activity implements OnClickListener {   @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);   LinearLayout layout = (LinearLayout) findViewById(R.id.layout); RadioGroup radioGroup = new RadioGroup(this);   LinearLayout.LayoutParams p = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT ); layout.addView(radioGroup, p);   … Continue reading

Posted in Android Examples Code | Tagged , , , , | Comments Off on Create RadioButton RadioGroup dynamically – Android sample
25,563 views

Create Button and TextView dynamically – Android sample

public class MainActivity extends Activity {   @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);   LinearLayout layout = (LinearLayout) findViewById(R.id.layout); TextView textView = new TextView(this); textView.setText("Text View "); LinearLayout.LayoutParams p = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT ); layout.addView(textView, p);   … Continue reading

Posted in Android Examples Code | Tagged , , , | Comments Off on Create Button and TextView dynamically – Android sample
19,928 views

Open url with browser if button clicked Android example.

Button, setOnClickListener, Intent.ACTION_VIEW, startActivity Android example.   Button mIdButtonHome = (Button)findViewById(R.id.idButtonHome); mIdButtonHome.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent browserIntent = new Intent( Intent.ACTION_VIEW, Uri.parse("http://android.okhelp.cz/category/software/")); startActivity(browserIntent); } });

Posted in Android Examples Code | Tagged , , , , | Comments Off on Open url with browser if button clicked Android example.
34,671 views

ImageView change image Android example

How to change the image dynamically in ImageView and button setOnClickListener Android sample. Main.java   ipackage cz.okhelp.my_game;   import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.ImageView;     public class Main extends Activity { private ImageView … Continue reading

Posted in Android Examples Code | Tagged , , , | Comments Off on ImageView change image Android example
3,115 views

Button Android

Google Android button example source code for developers. // get handle Button myButton; myButton = (Button)findViewById(R.id.idMyButton); //set focus myButton.requestFocus(); // set background image myButton.setBackgroundResource(R.drawable.backImage); // or myButton.setBackgroundDrawable(getResources().getDrawable( R.drawable.someImage));   // set visibility myButton.setVisibility(View.INVISIBLE); // VISIBLE   ///////// SET LISTENER Button … Continue reading

Posted in Android Examples Code | Tagged , , | Comments Off on Button Android