开发者

Help Me to resolve this error

package com.example.android.home;

import android.app.Activity;
import android.os.Bundle;
import android.widget.*;
import android.view.*;
public class HomeActivity extends Activity {
    /** Called when the activity is first created. */
  private EditText input;
  private EditText result;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setConten开发者_Go百科tView(R.layout.main);
        input = (EditText) findById(R.id.input1);
        result = (EditText) ***findById***(R.id.result); //Error:Undefined for the type HomeActivity

        input.addKeyListener(new View.OnKeyListener() {   Error: Undefined for the type EditText
            public boolean onKey(View v, int keycode, KeyEvent keyevent) {      
                if (keyevent.getAction() == KeyEvent.ACTION_UP) {            
                    doCalculation();      
                    }          
                return false;       
                }    
            }); 
            }
     private void doCalculation()
     {
             String strValue = input.getText().toString();
             int resultt = Integer.parseInt(strValue) * 2;
             result.setText("Result: "+ resultt);  

     }

}


As @Varun states, there is no findById() method. You are probably thinking of findViewById().

You would have found this on your own by examining any sample Android activity and seeing how it accesses the widgets. There are many sample activities in your SDK installation, plus online.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜