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条)

报告相同问题?

悬赏问题

  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿