当前位置:  编程技术>移动开发
本页文章导读:
    ▪http 1.1特点        http 1.1特性 http://www.7dtest.com/site/html/02/t-5102.htmlhttp 1.1 socket 没有断开 ......
    ▪ ListView跟SlidingDrawer        ListView和SlidingDrawer XML文件main.xml文件两个控件按钮btnListView和btnSlidingDrawer<Button                android:id="@+id/listView"                android:layout_width="wrap_content"         .........
    ▪ 寻常积累       平时积累 NSStirng去除空格[someStr stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; 替换NSString中的回车 空格 或者 \nstringElementValue = [stringElementValue stringByTrimmingCharactersInSet:[NSCh.........

[1]http 1.1特点
    来源: 互联网  发布时间: 2014-02-18
http 1.1特性
http://www.7dtest.com/site/html/02/t-5102.html

http 1.1 socket 没有断开

    
[2] ListView跟SlidingDrawer
    来源: 互联网  发布时间: 2014-02-18
ListView和SlidingDrawer
XML文件

main.xml文件
两个控件按钮btnListView和btnSlidingDrawer
<Button
                android:id="@+id/listView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/listviewStr" />

<Button
                android:id="@+id/btnSlipdingdrawer"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/slidingDrawerStr" />


mylistview.xml文件

一个控件ListView
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <ListView
        android:id="@+id/listView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    </ListView>  
   
</LinearLayout>



mylistview_item.xml文件

两个控制:一个ImageView和一个TextView

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="/blog_article/@drawable/a/index.html" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="TextView" />

</LinearLayout>


myslidingdrawer.xml文件


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <SlidingDrawer
        android:id="@+id/slidingDrawer1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:content="@+id/content"
        android:handle="@+id/handle" >

        <Button
            android:id="@+id/handle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Handle" />

        <LinearLayout
            android:id="@+id/content"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >
            <ListView
                android:id="@+id/slidingDrawerListView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1">
            </ListView>
        </LinearLayout>
    </SlidingDrawer>

</LinearLayout>


AndroidMainfest.xml文件

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.newer.p0202"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="8" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:label="@string/app_name"
            android:name=".P0202Activity" >
            <intent-filter >
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="MyListView"></activity>
        <activity android:name="MySlidingDrawer"></activity>
        <activity android:name="MyViewFlipper"></activity>
    </application>

</manifest>

java代码

P0202Activity类
主页面继承Activity实现OnClickListenere

public class P0202Activity extends Activity implements OnClickListener{
     public void onCreate(Bundle savedInstanceState){
          super.onCreate(savedInstenceState);
          setContentView(R.layout.main);

          //启动ListView Activity按钮
          Button btnListView = (Button)findViewById(R.id.listView);
          btnListView.setOnClickListener(this);

         
     }
     public void onClick(View v){
          switch(v.getId()){
          case R.id.listView:
               Intent intent = new Intent(this,MyListView.class);
               startActivity(intent);
               break;
          case R.id.btnSlidingdrawer:
               Intent intent2 = new Intent(this,MySlidingDrawer.class);
               startActivity(intent2);
               break;
          default:
               break;
          }
     }
}



MyListView类继承Activity

public class MyListView extends Activity{
     protected void onCreate(Bundle savedInstanceState)
         super.onCreate(savedInstanceState);
         setContentView(R.layout.mylistview);

         //模拟数据
         List<DataBean> dataList = new ArrayList<DataBean>();
         for(int idx=0;idx<20;idx++){
             //具体的每一条数据
             DataBean dataBean = new DataBean();
             dataBean.imageId = R.drawable.a;
             dataBean.imageDescription = "具体的说明"+idx;
             dataList.add(dataBean);
         }

         MyListViewAdapter myListViewAdapter = new MyListViewAdapter(dataList,this);
         //得到listview控件
         ListView listView = (ListView)findViewById(R.id.listView1);
         //设置适配器,让listview根据适配器来显示数据
         listView.setAdapter(myListViewAdapter);        
     }
}


创建一个类DataBean

public class DataBean{
    public int imageId;
    public String imageDescription;
}



创建一个类MyHandler

public class MyHandler{
    public ImageView imageView;
    public TextView textView;
}



适配器类:
MyListViewAdapter类继承BaseAdapter

public class MyListViewAdapter extends BaseAdapterP{
    public int getCount(){
        return dataList.size();
    }
    public Object getItem(int position){
        return null;
    }
    public long getItemId(int position){
        return 0;
    }
    public View getView(int position, View convertView, ViewGroup parent){
        //三种方式
        //LayoutInflater.from(context);
        //(LinearLayout)activity.getlayoutInflater();
        //LayoutInflater layoutInflater = (LayoutInflater)myContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        //样式膨胀(要从layout资源中动态的读取一个XML文档)
        //效率差的方式
        //LayoutInflater layoutInflater = (LayoutInflater)myContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        //LinearLayout lineanLayout = (LinearLayout)layoutInflater.inflater(R.layout.mylistview_item,null);
        //得到当前线性布局的两个控件
        //ImageView imageView = (ImageView)lineanLayout.findViewById(R.id.imageView1);
        //TextView textView = (TextView)lineanLayout.findViewById(R.id.textView1);
        //imageView.setImageResource(dataList.get(position).imageId);
        //textView.setText(dataList.get(position).imageDescription);
        //return lineanLayout;


        //效率高的方式
        MyHandler myHandler = new MyHandler();
        if(null == convertView){//刚开始第一次convertView里面是没有对象
            LayoutInflater layoutInflater = (LayoutInflater)myContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            LinearLayout lineanLayout = (LinearLayout)layoutInflater.inflater(R.layout.mylistview_item,null);
            //得到当前线性布局的两个控件
            ImageView imageView = (ImageView)lineanLayout.findViewById(R.id.imageView1);
            TextView textView = (TextView)lineanLayout.findViewById(R.id.textView1);
            myHandler.imageView = imageView;
            myHandler.textView = textView;
       
            convertView = lineanLayout;

        }
        myHandler = (MyHandler)convertView.getTag();
        myHandler.imageView.setImageResoure(dataList.get(position).imageId);
        myHandler.textView.setText(dataList.get(position).imageDescription);
        return convertView;
    }
}





MySlidingDrawer类继承Activity

public class MySlidingDrawer extends Activity{
     protected void onCreate(Bundler savedInstanceState){
          super.onCreate(savedInstanceState);
          setContentView(R.layout.myslidingdrawer);

          //模拟数据
          List<DataBean> dataList = new ArrayList<DataBean>();
          for(int idx=0;idx<20;idx++){
              //具体的每一条数据
              DataBean dataBean = new DataBean();
              dataBean.imageId = R.drawable.a;
              dataBean.imageDescription = "具体的说明"+idx;
              dataList.add(dataBean);
          }
          MyListViewAdapter myListViewAdapter = new MyListViewAdapter(dataList,this);
          ListView listView = (ListView)findViewById(R.id.slidingDrawerListView);
          listView.setAdapter(myListViewAdapter);
     }
}






















1 楼 asource 2012-05-07  
只可惜没有截图

    
[3] 寻常积累
    来源: 互联网  发布时间: 2014-02-18
平时积累
NSStirng去除空格
[someStr stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
替换NSString中的回车 空格 或者 \n
stringElementValue = [stringElementValue stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
获取info.plist文件中的值:
[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]
不让手机处于休眠状态
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];

    
最新技术文章:
▪Android开发之登录验证实例教程
▪Android开发之注册登录方法示例
▪Android获取手机SIM卡运营商信息的方法
▪Android实现将已发送的短信写入短信数据库的...
▪Android发送短信功能代码
▪Android根据电话号码获得联系人头像实例代码
▪Android中GPS定位的用法实例
▪Android实现退出时关闭所有Activity的方法
▪Android实现文件的分割和组装
▪Android录音应用实例教程
▪Android双击返回键退出程序的实现方法
▪Android实现侦听电池状态显示、电量及充电动...
▪Android获取当前已连接的wifi信号强度的方法
▪Android实现动态显示或隐藏密码输入框的内容
▪根据USER-AGENT判断手机类型并跳转到相应的app...
▪Android Touch事件分发过程详解
▪Android中实现为TextView添加多个可点击的文本
▪Android程序设计之AIDL实例详解
▪Android显式启动与隐式启动Activity的区别介绍
▪Android按钮单击事件的四种常用写法总结
▪Android消息处理机制Looper和Handler详解
▪Android实现Back功能代码片段总结
▪Android实用的代码片段 常用代码总结
▪Android实现弹出键盘的方法
▪Android中通过view方式获取当前Activity的屏幕截...
▪Android提高之自定义Menu(TabMenu)实现方法
▪Android提高之多方向抽屉实现方法
▪Android提高之MediaPlayer播放网络音频的实现方法...
▪Android提高之MediaPlayer播放网络视频的实现方法...
▪Android提高之手游转电视游戏的模拟操控
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3