Tag Archives: setonclicklistener

26,038 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
16,006 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
8,879 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.
26,486 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
2,712 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