android界面开发

关于界面控件的学习3【spinner、autocompletetextview...

Spinner控件

效果如下:

 

 

使用Spinner控件分为三个步骤:

1.修改res/layout/main.xml 添加Spinner控件

    <Spinner
        android:id="@+id/sp1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:drawSelectorOnTop="true"
        android:prompt="@string/planet_prompt"
    />

2.制作弹出菜单的数据源,该数据源可以来自xml,可以自己写Adapter接口(以后学习)
在 res/values修改strings.xml 添加

<string name="planet_prompt">Choose a planet</string>

在 res/values下新建array.xml

<resources>

    <string-array name="planets">
        <item>Mercury</item>
        <item>Venus</item>
        <item>Earth</item>
        <item>Mars</item>
        <item>Jupiter</item>
        <item>Saturn</item>
        <item>Uranus</item>
        <item>Neptune</item>
    </string-array>
   
</resources>

3.声明并实例化spinner类

Spinner sp=(Spinner)this.findViewById(R.id.sp1);ArrayAdapter adapter=ArrayAdapter.createFromResource(this, R.array.planets, android.R.layout.simple_spinner_dropdown_item);

sp.setAdapter(adapter);

AutoCompleteTextView控件

效果如下:

 

 

使用AutoCompleteTextView控件分为三个步骤:

1.修改res/layout/main.xml 添加AutoCompleteTextView控件

<AutoCompleteTextView
    android:id="@+id/ac1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
   />

2.定义AutoComplete的字符串

    static final String[] androidwords = new String[]{
    "yao","yuan","yaoyuanhua","yyh","yoganka","yaoyh","yaoandroid","gk14","gk1","g2"
    };

3.声明并实例化AutoCompleteTextView类

        AutoCompleteTextView ac=(AutoCompleteTextView)this.findViewById(R.id.ac1);
        ArrayAdapter adapter=new ArrayAdapter(this,android.R.layout.simple_dropdown_item_1line,androidwords);
        ac.setAdapter(adapter);

NotificationBar控件

 

 

shownotification("Hello AndroidQQ群697668来新的消息了");

private void shownotification(String tab)
{
   NotificationManager barmanager=(NotificationManager)getSystemService(this.NOTIFICATION_SERVICE);
   Notification msg=new android.app.Notification(android.R.drawable.stat_notify_chat,tab,System.currentTimeMillis());
  
   PendingIntent contentIntent=PendingIntent.getActivity(this, 0, new Intent(this,YaoTest.class), PendingIntent.FLAG_ONE_SHOT);
   msg.setLatestEventInfo(this, "是的,you make it", "yes", contentIntent);
   barmanager.notify(0, msg);
}

为了您的安全,请只打开来源可靠的网址

打开网站    取消

来自: http://hi.baidu.com/gk14/blog/item/b2f7083396ee8df41b4cff2a.html

转载于:https://www.cnblogs.com/a780397897/archive/2012/06/25/2560932.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值