android - Why "OnClickListener" is not working -


I do not understand why this simple code is not working.
This code believes the color of the button is set to blue, all this is that I have just added a newly created project:

  last button btn = (button ) FindViewById (R.id.button1); Btn.setOnClickListener (New View.OnClickListener () {@Override Public Zero Click on (see V)} // click on btn.setTextColor (color.BLUE);}}};   

Full code:

  package com.example.b; Import android.graphics.color; Importroid.os.Bundle; Import android.support.v4.app.Fragment; Import android.support.v7.app.ActionBarActivity; Import android.view.LayoutInflater; Import android.view.Menu; Import android.view.MenuItem; Import android.view.View; Import android.view.ViewGroup; Import android.widget.Button; Public Class Main Activity ActionBarActivity (Creates the bundled saved instenstate) on Protected Zero {Super.Creative InstantState}; SetContentView (R.layout.activity_main); Find the last button BTN = (button) VVBIID (R.B. button 1); Btn.setOnClickListener (New View.OnClickListener () {@Override Public Zero Click on (see V)} // click on btn.setTextColor (color.BLUE);}}}; If (savedInstanceState == zero) {getSupportFragmentManager () BeginTransaction () .add (R.id.container, new placeholder fragment ()) .commit (); }} @ Override Public Boolean On Crate Option Menu (Menu Menu) {// Increase Menu; It adds the item to the Action Bar if it exists GetMenuInflater (). Fulao (R. menu menu, menu); Back true; } @ Override Public Boolean On Option Itam Select (menu item) {// Handle action bar item here clicks the action bar will automatically handle clicks on the home / up button automatically, so long as / when You specify a parental activity in AndroidManifest.xml. Int id = item.getItemId (); If (id == R.id.action_settings) {return true; } Return Super.Options item selected (item); } / ** * A placeholder piece containing a simple view. * / Public static class placeholder Fregment (public placeholder fragment) () {} @ See override public Crete View (Leautifltr Inflatr, View Group container, bundle saved Instensstet) {See Rutwu = Inflaiar Inflat (r. Leteft. Framentment_man, container, Falls); Return root view; }}}}    

Most likely that the button is in the segment and there is no activity If so, take your search vibidibi and your satonclic code into your Playworldfragment.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -