• 安卓app_sl3_18_19列表视图


    <!-- sl3_19 -->
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context="com.example.sl3_18.MainActivity" >
    
        <ListView
            android:id="@+id/listView1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:divider="@drawable/greendivider"
            android:dividerHeight="3dp"
            android:footerDividersEnabled="false"
            android:headerDividersEnabled="false"
            android:layout_alignParentTop="true" >
        </ListView>
    
    </RelativeLayout>
    <!-- array.xml -->
    <resources>
    
        <!--
            Base application theme, dependent on API level. This theme is replaced
            by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
        -->
        <style name="AppBaseTheme" parent="android:Theme.Light">
            <!--
                Theme customizations available in newer API levels can go in
                res/values-vXX/styles.xml, while customizations related to
                backward-compatibility can go here.
            -->
        </style>
    
        <!-- Application theme. -->
        <style name="AppTheme" parent="AppBaseTheme">
            <!-- All customizations that are NOT specific to a particular API-level can go here. -->
        </style>
        <string-array 
            name="ctype">
            <item>情景模式</item>
            <item>主题模式</item>
            <item>手机</item>
            <item>程序管理</item>
            <item>通话设置</item>
            <item>连接功能</item>
        </string-array>
    
    </resources>
    package com.example.sl3_18;
    //与sl3_19
    import android.app.Activity;
    import android.os.Bundle;
    import android.view.Menu;
    import android.view.MenuItem;
    import android.view.View;
    import android.widget.AdapterView;
    import android.widget.AdapterView.OnItemClickListener;
    import android.widget.ArrayAdapter;
    import android.widget.ImageView;
    import android.widget.ListView;
    import android.widget.Toast;
    
    public class MainActivity extends Activity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            final ListView listView=(ListView)findViewById(R.id.listView1);
            listView.addHeaderView(line());
            ArrayAdapter<CharSequence> adapter= ArrayAdapter.createFromResource(this, R.array.ctype, android.R.layout.simple_list_item_checked);
            listView.setAdapter(adapter);
            listView.addFooterView(line());
            listView.setOnItemClickListener(new OnItemClickListener(){
    
                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                    // TODO 自动生成的方法存根
                    String result=parent.getItemAtPosition(position).toString();
                    Toast.makeText(MainActivity.this, result, Toast.LENGTH_SHORT).show();
                    
                }
                
            });
            
        }
    
        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            // Inflate the menu; this adds items to the action bar if it is present.
            getMenuInflater().inflate(R.menu.main, menu);
            return true;
        }
    
        @Override
        public boolean onOptionsItemSelected(MenuItem item) {
            // Handle action bar item clicks here. The action bar will
            // automatically handle clicks on the Home/Up button, so long
            // as you specify a parent activity in AndroidManifest.xml.
            int id = item.getItemId();
            if (id == R.id.action_settings) {
                return true;
            }
            return super.onOptionsItemSelected(item);
        }
        private View line()
        {
            ImageView image=new ImageView(this);
            image.setImageResource(R.drawable.line1);
            return image;
        }
    }
  • 相关阅读:
    云原生网关 Kong 和Kong 管理UI 的完全安装攻略
    微服务最强开源流量网关Kong
    如何在java中判断一个字符串是否是数字
    设计模式之责任链模式讲解
    我的第一个react native
    封装缓动动画3
    封装缓动动画2
    封装缓动动画1
    获取用户选中的文字内容
    窗口事件onresize
  • 原文地址:https://www.cnblogs.com/txwtech/p/15911476.html
Copyright © 2020-2023  润新知