【问题标题】:Whats a simple way to get a text input Alertdialog box on an Android什么是在 Android 上获取文本输入警报对话框的简单方法
【发布时间】:2013-05-21 09:00:03
【问题描述】:

我想得到密码。一个简单的文本输入对话框。有什么简单的方法吗?

在 iPhone 中它是这样创建的。

style : Ti.UI.iphone.AlertDialogStyle.SECURE_TEXT_INPUT

但是在android中我该怎么做呢??

【问题讨论】:

    标签: javascript titanium titanium-mobile


    【解决方案1】:

    在 UI.AlertDialog 中使用 androidView 属性并添加一个 TextField。

    【讨论】:

      【解决方案2】:

      目前 Appcelerator 不提供此类功能。但是您可以通过使用视图、文本字段和按钮以简单的方式完成,如下所示

      var vwAlert = Ti.UI.createView({
          backgroundColor : '#311919',
          width       : '90%',
          height      : '40%',
          layout      : 'vertical',
          borderRadius: 5
      }); 
      
      var lblMessage = Ti.UI.createLabel({
          text        : 'Alert',
          top         : 10,
          color       : 'white',
          font        : {fontWeight : 'bold', fontSize : '16'}
      });
      
      var textField = Ti.UI.createTextField({
          width       :  '90%',
          top         :  '20',
              passwordMask: true,
          hintText    : 'Enter your text here',
          borderStyle     : Ti.UI.INPUT_BORDERSTYLE_ROUNDED,
          returnKeyType   : Ti.UI.RETURNKEY_RETURN,
          maxLength       : 70
      });
      
      var btnOK = Ti.UI.createButton({
          title   : 'OK',
          width   : '43%',
          top     : '25',
          font    : {fontWeight : 'bold', fontSize : '16'}
      });
      
      vwAlert.add(lblMessage);
      vwAlert.add(textField);
      vwAlert.add(btnOK);
      

      上面的视图看起来像一个警报对话框,因为它是自定义的。这样就可以了:)

      【讨论】:

        【解决方案3】:

        你需要一个带有android:inputType="textPassword"的EditText

        【讨论】:

          【解决方案4】:
          EditText tf = new EditText(context);
          
          tf.setTransformationMethod(PasswordTransformationMethod.getInstance());
          

          或在xml中

          android:inputType="textPassword"
          

          【讨论】:

          • 我想他是用钛做的。
          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2014-11-23
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2021-09-21
          • 1970-01-01
          相关资源
          最近更新 更多