当前位置:  编程技术>移动开发
本页文章导读:
    ▪在虚拟机中装配apk软件        在虚拟机中安装apk软件 Android APK文件在电脑上面运行方法   apk是Android系统的发布的工程包,很多时候我们想在电脑上而非Android手机上面运行它。下面就提供下Android APK文件在电脑上面运.........
    ▪ 关于弹出对话框时 标题栏的抖动有关问题        关于弹出对话框时 标题栏的抖动问题 遇到这个问题是在camera的MenuHelper类中,我们需要的处理就是添加语句:AlertDialog ad = adBuilder.create();ad.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,.........
    ▪ ListView setOnItemSelectedListener setOnItemClickListener 差别       ListView setOnItemSelectedListener setOnItemClickListener 区别 OnItemSelectedListener.setOnItemSelectedListener() 指的是鼠标获得一个条目的焦点,字面上理解是选择一个条目   OnItemClickListener.setOnItemClickListener() 指.........

[1]在虚拟机中装配apk软件
    来源: 互联网  发布时间: 2014-02-18
在虚拟机中安装apk软件
Android APK文件在电脑上面运行方法  
apk是Android系统的发布的工程包,很多时候我们想在电脑上而非Android手机上面运行它。下面就提供下Android APK文件在电脑上面运行方法。



第一步:下载并解压android SDK到自己硬盘上。



第二步:在系统环境变量中增加系统变量SDK_ROOT,并让它指向android SDK安装目录之下的tools文件夹。



第三步:在cmd命令状态下进入android SDK安装目录之下的tools文件夹,并使用“android create avd --name Jackliao --target 3”创建一个叫“jackliao”(可以自行修改)的ADV。



第四步:继续在cmd命令状态下输入命令“emulator -avd jackliao”,既可以启动模拟器进入Android手机的模拟界面了。不要关闭此界面。



第五步:将你要运行的xxx.apk文件复制到android SDK安装目录之下的tools文件夹中。



第六步:新开一个cmd命令窗口,并进入android SDK安装目录之下的tools文件夹中输入命令“adb install xxx.apk”,这个apk将会部署到你当前的模拟器中去,这样你刷新Android手机的模拟界面就可以看到你安装的程序了。

本文摘自http://www.eoeandroid.com/thread-26290-1-1.html中7楼的回答

    
[2] 关于弹出对话框时 标题栏的抖动有关问题
    来源: 互联网  发布时间: 2014-02-18
关于弹出对话框时 标题栏的抖动问题
遇到这个问题是在camera的MenuHelper类中,我们需要的处理就是添加语句:

AlertDialog ad = adBuilder.create();
ad.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
ad.show();
,详细如下

if ((inclusions & INCLUDE_DETAILS_MENU) != 0) {
            MenuItem detailsMenu = menu.add(0, 0, 80, R.string.details)
                    .setOnMenuItemClickListener(
                            new MenuItem.OnMenuItemClickListener() {
                                public boolean onMenuItemClick(MenuItem item) {
                                    onInvoke.run(new MenuCallback() {
                                        public void run(Uri u,
                                                ImageManager.IImage image) {
                                            if (image == null)
                                                return;

                                            AlertDialog.Builder builder = new AlertDialog.Builder(
                                                    activity);

                                            final View d = View.inflate(
                                                    activity,
                                                    R.layout.detailsview, null);

                                            ImageView imageView = (ImageView) d
                                                    .findViewById(R.id.details_thumbnail_image);
                                            imageView.setImageBitmap(image
                                                    .miniThumbBitmap());

                                            TextView textView = (TextView) d
                                                    .findViewById(R.id.details_image_title);
                                            textView.setText(image
                                                    .getDisplayName());

                                            long length = getImageFileSize(image);
                                            String lengthString = lengthString = length < 0 ? ""
                                                    : android.text.format.Formatter
                                                            .formatFileSize(
                                                                    activity,
                                                                    length);
                                            ((TextView) d
                                                    .findViewById(R.id.details_file_size_value))
                                                    .setText(lengthString);

                                            int dimensionWidth = 0;
                                            int dimensionHeight = 0;
                                            if (isImage) {
                                                dimensionWidth = image
                                                        .getWidth();
                                                dimensionHeight = image
                                                        .getHeight();
                                                d
                                                        .findViewById(
                                                                R.id.details_duration_row)
                                                        .setVisibility(
                                                                View.GONE);
                                                d
                                                        .findViewById(
                                                                R.id.details_frame_rate_row)
                                                        .setVisibility(
                                                                View.GONE);
                                                d
                                                        .findViewById(
                                                                R.id.details_bit_rate_row)
                                                        .setVisibility(
                                                                View.GONE);
                                                d
                                                        .findViewById(
                                                                R.id.details_format_row)
                                                        .setVisibility(
                                                                View.GONE);
                                                d.findViewById(
                                                        R.id.details_codec_row)
                                                        .setVisibility(
                                                                View.GONE);
                                            } else {
                                                MediaMetadataRetriever retriever = new MediaMetadataRetriever();
                                                try {
                                                    retriever
                                                            .setMode(MediaMetadataRetriever.MODE_GET_METADATA_ONLY);
                                                    retriever
                                                            .setDataSource(image
                                                                    .getDataPath());
                                                    try {
                                                        dimensionWidth = Integer
                                                                .parseInt(retriever
                                                                        .extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH));
                                                        dimensionHeight = Integer
                                                                .parseInt(retriever
                                                                        .extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT));
                                                    } catch (NumberFormatException e) {
                                                        dimensionWidth = 0;
                                                        dimensionHeight = 0;
                                                    }

                                                    try {
                                                        int durationMs = Integer
                                                                .parseInt(retriever
                                                                        .extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION));
                                                        String durationValue = formatDuration(
                                                                activity,
                                                                durationMs);
                                                        ((TextView) d
                                                                .findViewById(R.id.details_duration_value))
                                                                .setText(durationValue);
                                                    } catch (NumberFormatException e) {
                                                        d
                                                                .findViewById(
                                                                        R.id.details_frame_rate_row)
                                                                .setVisibility(
                                                                        View.GONE);
                                                    }

                                                    try {
                                                        String frame_rate = String
                                                                .format(
                                                                        activity
                                                                                .getString(R.string.details_fps),
                                                                        Integer
                                                                                .parseInt(retriever
                                                                                        .extractMetadata(MediaMetadataRetriever.METADATA_KEY_FRAME_RATE)));
                                                        ((TextView) d
                                                                .findViewById(R.id.details_frame_rate_value))
                                                                .setText(frame_rate);
                                                    } catch (NumberFormatException e) {
                                                        d
                                                                .findViewById(
                                                                        R.id.details_frame_rate_row)
                                                                .setVisibility(
                                                                        View.GONE);
                                                    }

                                                    try {
                                                        long bitRate = Long
                                                                .parseLong(retriever
                                                                        .extractMetadata(MediaMetadataRetriever.METADATA_KEY_BIT_RATE));
                                                        String bps;
                                                        if (bitRate < 1000000) {
                                                            bps = String
                                                                    .format(
                                                                            activity
                                                                                    .getString(R.string.details_kbps),
                                                                            bitRate / 1000);
                                                        } else {
                                                            bps = String
                                                                    .format(
                                                                            activity
                                                                                    .getString(R.string.details_mbps),
                                                                            ((double) bitRate) / 1000000.0);
                                                        }
                                                        ((TextView) d
                                                                .findViewById(R.id.details_bit_rate_value))
                                                                .setText(bps);
                                                    } catch (NumberFormatException e) {
                                                        d
                                                                .findViewById(
                                                                        R.id.details_bit_rate_row)
                                                                .setVisibility(
                                                                        View.GONE);
                                                    }

                                                    String format = retriever
                                                            .extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_FORMAT);
                                                    ((TextView) d
                                                            .findViewById(R.id.details_format_value))
                                                            .setText(format);

                                                    String codec = retriever
                                                            .extractMetadata(MediaMetadataRetriever.METADATA_KEY_CODEC);

                                                    if (codec == null) {
                                                        d
                                                                .findViewById(
                                                                        R.id.details_codec_row)
                                                                .setVisibility(
                                                                        View.GONE);
                                                    } else {
                                                        ((TextView) d
                                                                .findViewById(R.id.details_codec_value))
                                                                .setText(codec);
                                                    }
                                                } catch (RuntimeException ex) {
                                                    // Assume this is a corrupt
                                                    // video file.
                                                } finally {
                                                    try {
                                                        retriever.release();
                                                    } catch (RuntimeException ex) {
                                                        // Ignore failures while
                                                        // cleaning up.
                                                    }
                                                }
                                            }

                                            String dimensionsString = String
                                                    .format(
                                                            activity
                                                                    .getString(R.string.details_dimension_x),
                                                            dimensionWidth,
                                                            dimensionHeight);
                                            ((TextView) d
                                                    .findViewById(R.id.details_resolution_value))
                                                    .setText(dimensionsString);

                                            String dateString = "";
                                            long dateTaken = image
                                                    .getDateTaken();
                                            if (dateTaken != 0) {
                                                java.util.Date date = new java.util.Date(
                                                        image.getDateTaken());
                                                java.text.SimpleDateFormat dateFormat = new java.text.SimpleDateFormat();
                                                dateString = dateFormat
                                                        .format(date);

                                                ((TextView) d
                                                        .findViewById(R.id.details_date_taken_value))
                                                        .setText(dateString);
                                            } else {
                                                d
                                                        .findViewById(
                                                                R.id.details_date_taken_row)
                                                        .setVisibility(
                                                                View.GONE);
                                            }

                                            builder
                                                    .setNeutralButton(
                                                            R.string.details_ok,
                                                            new DialogInterface.OnClickListener() {
                                                                public void onClick(
                                                                        DialogInterface dialog,
                                                                        int which) {
                                                                    dialog
                                                                            .dismiss();
                                                                }
                                                            });

                                            builder
                                                    .setIcon(
                                                            android.R.drawable.ic_dialog_info)
                                                    .setTitle(
                                                            R.string.details_panel_title)
                                                    .setView(d);
                                           
                                            AlertDialog able = builder.create();
                                            able
                                                    .getWindow()
                                                    .setFlags(
                                                            WindowManager.LayoutParams.FLAG_FULLSCREEN,
                                                            WindowManager.LayoutParams.FLAG_FULLSCREEN);
                                            able.show();                                        }
                                    });
                                    return true;
                                }
                            });
            detailsMenu.setIcon(R.drawable.ic_menu_view_details);
        }

    
[3] ListView setOnItemSelectedListener setOnItemClickListener 差别
    来源: 互联网  发布时间: 2014-02-18
ListView setOnItemSelectedListener setOnItemClickListener 区别

OnItemSelectedListener.setOnItemSelectedListener()

指的是鼠标获得一个条目的焦点,字面上理解是选择一个条目

 

OnItemClickListener.setOnItemClickListener()

指的是你单击一个条目。

如果你从鼠标滚动(或者说选择一个条目)过渡到单击一个条目,都会在调用OnItemClickListener.setOnItemClickListener()之前调用一次OnItemSelectedListener.onNothingSelected()。貌似是因为你单击了一个条目之前就默认你没有选择任何条目,所以会触发一个OnItemSelectedListener.onNothingSelected()

 

有关ListView中数据改变时,怎么办。

在你改变数据的后面加上一句adapter.notifyDataSetChanged(),adapter是Adapter的实例化对象,android自带的可以,你自己写的Adapter也可以

 

有关网上的 ListView中用到CheckBox,CheckBox的状态混乱的问题。

· 我敢说你们一定是用了convertView/ViewHolder 这种缓存技术。如果你不用这种技术,就没有CheckBox状态混乱的情况出现;但是取而代之的是你CheckBox的状态没有被保存,因为BaseAdapter中的getView()方法只会绘出ListView的每一行,他没有义务为你保存CheckBox的状态。需要你自己去在getView中做一些工作。

· 无论你采不采用convertView/ViewHolder 这种缓存技术,你可以通过这种方法解决CheckBox的状态保存与一致的问题。

 

就是设置一个Map<Integer, Boolean>  checkState=new HashMap<Integer, Boolean>();保存你当前选择的状态。然后在BaseAdapter的getView()方法中通过CheckBox checkBox=(CheckBox)convertView.findViewById(R.id.check)中获取到CheckBox,然后再checkBox.setChecked()就可以啦。很简单把?

· 其实还是用convertView/ViewHolder 这种缓存技术比较好,这样子你浏览ListView的时候速度很快。而不采用convertView/ViewHolder 这种缓存技术的时候,你会明显感觉ListView很卡

· convertView/ViewHolder 缓存技术的实质,其实就是convertView的复用,因为我在查看convertView是否为null的时候,只有7次它输出null,其余都是convertView不为null。也就是说convertView这个对象引用只有7个(每个手机不同,就是一个屏幕最多容纳的条目数)。convertView/ViewHolder 其实是在复用每一个条目的View。只让这7个引用对应7个View的实例,而不是我们每次都给一个引用建立一个新的View实例。这样子,在ListView绘制调用getView的时候,我们只建立了7个View实例,只是每次把View中的内容改变了一下,比如TextView.setText(str)。这样子程序就很快

 

075       public class MyAdapter extends BaseAdapter{ 

076   

077           private LayoutInflater mInflater; 

078            

079            

080           public MyAdapter(Context context){ 

081               this .mInflater = LayoutInflater.from(context); 

082           } 

083           @Override 

084           public int getCount() { 

085               // TODO Auto-generated method stub 

086               return mData.size(); 

087           } 

088   

089           @Override 

090           public Object getItem( int arg0) { 

091               // TODO Auto-generated method stub 

092               return null ; 

093           } 

094   

095           @Override 

096           public long getItemId( int arg0) { 

097               // TODO Auto-generated method stub 

098               return 0 ; 

099           } 

100   

101           @Override 

102           public View getView( int position, View convertView, ViewGroup parent) { 

103                

104               ViewHolder holder = null ; 

105               if (convertView == null ) { 

106                    

107                   holder= new ViewHolder();  

108                    

109                   convertView = mInflater.inflate(R.layout.vlist2, null ); 

110                   holder.img = (ImageView)convertView.findViewById(R.id.img); 

111                   holder.title = (TextView)convertView.findViewById(R.id.title); 

112                   holder.info = (TextView)convertView.findViewById(R.id.info); 

113                   holder.viewBtn = (Button)convertView.findViewById(R.id.view_btn); 

114                   convertView.setTag(holder); 

115                    

116               } else { 

117                    

118                   holder = (ViewHolder)convertView.getTag(); 

119               } 

120                

121                

122               holder.img.setBackgroundResource((Integer)mData.get(position).get( "img" )); 

123               holder.title.setText((String)mData.get(position).get( "title" )); 

124               holder.info.setText((String)mData.get(position).get( "info" )); 

125                

126               holder.viewBtn.setOnClickListener( new View.OnClickListener() { 

127                    

128                   @Override 

129                   public void onClick(View v) { 

130                       showInfo();                 

131                   } 

132               }); 

133                

134                

135               return convertView; 

136           } 

137            

138       } 

 

· 有关 convertView/ViewHolder 缓存技术参见网址的最后一种方法    http://www.cnblogs.com/allin/archive/2010/05/11/1732200.htm

 

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/cocodehouse/archive/2010/11/22/6026884.aspx


    
最新技术文章:
▪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