super.onCreate(savedInstanceState); 
        setContentView(R.layout.main);         //根据id找到控件并实例化它         mobileText = (EditText)findViewById(R.id.MobileEditText );//
        contText = (EditText)findViewById(R.id.ContEditText);         sendBtn = (Button)findViewById(R.id.SendButton);         //发送按钮的处理事件         sendBtn.setOnClickListener(new OnClickListener() {       public void onClick(View v) { 
            String content = contText.getText().toString(); 
            String mobile = mobileText.getText().toString(); 
//获得发送短信的管理器,使用的是android.telephony.SmsManager 
            SmsManager smsManager = SmsManager.getDefault(); //如果短信内容过长则分段发送          if(content.length() > 70){ 
//使用短信管理器进行短信内容的分段,返回分成的段 
            ArrayList<String> contents = smsManager.divideMessage(content); 
               for(String msg : contents)
               { 
                smsManager.sendTextMessage(mobile, null, msg, null, null);
               }
//使用短信管理器发送短信内容 //参数一为短信接收者 //参数三为短信内容 //其他可以设为null //否则一次过发送 }else{ smsManager.sendTextMessage(mobile, null, content, null, null); } //吐司,用来显示发送成功的提示    Toast.makeText(SMSActivity.this, R.string.sucTxt, Toast.LENGTH_SHORT).show(); } });               //!!!可以通过启动两个模拟器进行测试,发送短信时就拨另一个的端口号(如5554等)就行了!!!     } 
}这个mobileText = (EditText)findViewById(R.id.MobileEditText );里面的R是什么意思,何处定义啊?

解决方案 »

  1.   

    public static final class RR.java 创建一个命名空间,以保存字符串资源ID
      

  2.   

    呵呵,新手来逛逛了。yiyaaixuexi说得好啊
      

  3.   

    这个R类是自动生成的,
    lz应该会写android的界面吧,界面上的控件定义后,会在R类中生成相应的id。不知道我说的明白不。 mobileText = (EditText)findViewById(R.id.MobileEditText );//
      contText = (EditText)findViewById(R.id.ContEditText);    sendBtn = (Button)findViewById(R.id.SendButton);  这3个控件分别是两个EditText和Button详解:http://blog.csdn.net/lincyang/archive/2010/06/17/5675522.aspx