【问题标题】:How to make a text change you from one screen to another [closed]如何使文本将您从一个屏幕更改为另一个[关闭]
【发布时间】:2014-07-01 10:31:41
【问题描述】:

如何使文本将您从一个屏幕变为另一个屏幕。 不是按钮,文本,我只需要知道在.java中添加什么

【问题讨论】:

  • 您需要添加代码。
  • 可能只有我一个人,但我不知道你在问什么。
  • 欢迎来到 Stack Overflow..亲爱的用户不要指望堆栈溢出成员为您的想法编写代码..如果您对代码有任何疑问,请花一些精力编写代码并询问 SO 成员..
  • 您是指用户输入的文本还是文本 (SMS) 消息?

标签: java android xml eclipse


【解决方案1】:

也许您想使用 TextView 而不是 Button...在这种情况下,让您的 TextView 在您的 xml 中可点击:true,然后您可以为其设置一个 onClickListener。 通过 java 中的 TextView.setOnClickListener(new OnClickListener....) 或 xml 中的 android:onClick。就像按钮一样。

【讨论】:

    【解决方案2】:

    我想您是指通过键入内容而不是单击按钮从一个屏幕(活动)更改为另一个屏幕(活动)。如果是这种情况,请使用 TextWatcher 并在更改时检查您的字符串(或命令)并移至下一个屏幕。类似的东西。

    textView.addTextChangedListener(new TextWatcher(){
        public void afterTextChanged(Editable s) {}
        public void beforeTextChanged(CharSequence s, int start, int count, int after){}
        public void onTextChanged(CharSequence s, int start, int before, int count){
            if("second".equalsIgnoreCase(s)){
                Intent intent = new Intent(this, SecondActivity.class);
                startActivity(intent);
                        }
        }
    }); 
    

    【讨论】:

      【解决方案3】:
      step 1 : pass text from screen 1 to screen 2
      step 2 : in OnCreate() method of screen 2 , recieve and change the text according to your requirement
      

      但我个人觉得你想为每个屏幕显示一些屏幕信息是吗??

      【讨论】:

      • @Markab:有帮助吗,您的具体要求是什么??
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-04
      • 1970-01-01
      • 2020-09-03
      • 1970-01-01
      • 2010-11-09
      • 1970-01-01
      相关资源
      最近更新 更多