Einzelnen Beitrag anzeigen
Alt 19.05.2010, 12:03   #7 (permalink)
Android Guru

Modell: T-Mobile G1, Nexus One, Samsung Galaxy Tab 10.1, Samsung Galaxy Nexus

Registriert seit: 04.05.2009
Beiträge: 1.599
Abgegebene Danke: 128
Erhielt 210 Danke für 193 Beiträge
Standard AW: extends view + onDraw() + listener

Code:
 ////////////////////////////////////////////////////////////////////////////////////////////   
     // Set Click Listener
        inputValuefromEdittext.setOnEditorActionListener(new OnEditorActionListener()
        {
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event)
          {
              if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)
              {
              
                  //speed = getValue and cast to double
                  int speed = Integer.parseInt(inputValuefromEdittext.getText().toString());
 //error->        mCustomDrawableView.setSpeed(speed);
                  ///Textview for Inputvalue
                  TextView velocityValue = (TextView)findViewById(R.id.EditTextValue);
                  velocityValue.setText( speed + "ms");
              }
              return false;
          }
        });
Da hast du doch deine anonyme Klasse...
Richtig wäre es mit implements so:
Code:
package com.jb;

import android.app.Activity;
import android.os.Bundle;
import android.widget.EditText; 
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;
import android.view.KeyEvent;
import android.view.View;
import android.os.Bundle;







public class  gravity_Game extends Activity implements OnEditorActionListener
{
    
    // Declare our Views, so we can access them later
    private EditText inputValuefromEdittext;
    

    /////////////////////////////////////////////////////////////////////////////////////////////
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        ///    
        inputValuefromEdittext = (EditText)findViewById(R.id.EditText01);
        
         ///add View to activity View
        MyDrawableView  mCustomDrawableView = new MyDrawableView(this);
        ((LinearLayout)findViewById(R.id.layout3)).addView(mCustomDrawableView); 
     ////////////////////////////////////////////////////////////////////////////////////////////   
     // Set Click Listener
        inputValuefromEdittext.setOnEditorActionListener(this); 
            
     //////////////////////////////////////////////////////////////////////////////////////////////   
     ///spinner
        Spinner s1 = (Spinner)findViewById(R.id.Planets);
        ArrayAdapter<CharSequence> adapter =
        ArrayAdapter.createFromResource(this,R.array.Planeten, android.R.layout.simple_spinner_item);
        s1.setAdapter(adapter); 
     /////////////////////////////////////////////////////////////////////////////////////////////
      
     
    }


    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
        
if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)
              {
              
                  //speed = getValue and cast to double
                  int speed = Integer.parseInt(inputValuefromEdittext.getText().toString());
 //error->        mCustomDrawableView.setSpeed(speed);
                  ///Textview for Inputvalue
                  TextView velocityValue = (TextView)findViewById(R.id.EditTextValue);
                  velocityValue.setText( speed + "ms");
              }
              return false;
    }
 
    
}
the_alien ist offline   Mit Zitat antworten
Folgender Benutzer bedankt sich bei the_alien für diesen Beitrag:
jim (19.05.2010)