O_Casper_ne 2013-08-05 05:18 采纳率: 7.7%
浏览 2208
已采纳

TextView 不能在其它的 activity 中显示?

我想传递数据到其它的activities除了现在这个。谁能告诉我问题出现在哪里。我现在获得的唯一的错误是TextView showmsg不能在新的activity中显示。这是为什么啊?

 public class MyScanActivity extends Activity
{

private static final String MY_CARDIO_APP_TOKEN = "NOT THE PROBLEM";
final String TAG = getClass().getName();
private Button scanButton;
private TextView resultTextView;
private Button buttonBack;
private TextView showmsg;
private int MY_SCAN_REQUEST_CODE = 100; // arbitrary int

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.myscan);

    Intent in = getIntent();
    if (in.getCharSequenceExtra("usr") != null) {
        final TextView setmsg = (TextView)findViewById(R.id.showmsg);
        setmsg.setText(in.getCharSequenceExtra("usr"));             
    }

    resultTextView = (TextView)findViewById(R.id.resultTextView);
    scanButton = (Button)findViewById(R.id.scanButton);
    buttonBack = (Button)findViewById(R.id.buttonBack);
    showmsg = (TextView) findViewById(R.id.showmsg);
  • 写回答

2条回答 默认 最新

  • Curie-87 2013-08-05 07:45
    关注

    1.在 TextView showmsg 中使用 android:text="TEST",然后在 xml 文件输入一些简单的 text 来检查 view。
    2. 在 debugger 中你可以使用 findViewById() 再次检查。
    3. 你传递的 text 没有显示出来,你应该创建一个日志语句,比如: Log.v(TAG, "Passed text is " + in.getCharSequenceExtra("urs"));

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图