Okhelp.cz

Recepty, články, nápady, programování. Dříve dum-zahrada, finance, internet a know-how.okhelp.cz Pro lepší výsledky hledání používejte i diakritiku.

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 myButton =(Button)findViewById(R.id.button1);
        myButton.setOnClickListener(new Button.OnClickListener() {
            public void onClick(View v) {
                Toast.makeText(getApplicationContext(), "AHOJ",
                    Toast.LENGTH_LONG).show();
            }
        });	

// or set onClickListener
 myButton.setOnClickListener(myListener);
//end onCreate .....
   private OnClickListener myListener = new OnClickListener() {
        public void onClick(View v) {

        }
   }




396LW NO topic_id




AD

Další témata ....(Topics)


32

Create array of strings in xml file Android example | create-array-of-strings-in-xml-file-android-example


Example source code for Android developers how create array of strings in *.xml file.
You can using array of strings in Spinner ( combobox - dropdown list ) or ListView etc.

<resources>
    <string-array name="colors">
        <item>red</item>
        <item>orange</item>
        <item>yellow</item>
        <item>green</item>
        <item>blue</item>
    </string-array>
</resources>
270

How to add or remove widgets home screen android 4 | how-to-add-or-remove-widgets-home-screen-android-4


Video tutorial
How to add or remove widgets home screen Android 4.