美文网首页
Android Day 1

Android Day 1

作者: slimsallen | 来源:发表于2017-06-01 17:55 被阅读0次

不得不说这么多IDE Android studio 的安装 是最费事的 不过好在还是安装好了.
先附上今天Demo地址 github

要点回顾

  • 去掉标题栏 styles 添加
<item name="windowNoTitle">true</item>

*限制输入框输入

 passwordText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(20)});

监听方法

  @Override
            public void afterTextChanged(Editable s) {

                Editable editable = userNameText.getText();
                int len = editable.length();

                if(len > maxInputNumer)
                {
                    int selEndIndex = Selection.getSelectionEnd(editable);
                    String str = editable.toString();
                    //截取新字符串
                    String newStr = str.substring(0,maxInputNumer);
                    userNameText.setText(newStr);
                    editable = userNameText.getText();

                    //新字符串的长度
                    int newLen = editable.length();
                    //旧光标位置超过字符串长度
                    if(selEndIndex > newLen)
                    {
                        selEndIndex = editable.length();
                    }
                    //设置新光标所在的位置
                    Selection.setSelection(editable, selEndIndex);

                }

            }
  • 类名跳转Activity
 Intent ac = new Intent(MainActivity.this,HomeActivity.class);
  startActivity(ac);
  • 一个Activity对应一个布局

ListView

实现ListView的大致步骤是:
* 新建数据适配器
* 添加数据源的到数据适配器
* 视图加载适配器

SimpleAdapter又叫做简单适配器,可以实现自定义的item视图,主要用来绑定复杂格式的数据。数据源只能是特定的泛型集合。

ongoing...

相关文章

网友评论

      本文标题:Android Day 1

      本文链接:https://www.haomeiwen.com/subject/oymefxtx.html