当前位置:  编程技术>移动开发
本页文章导读:
    ▪手机蓝牙客种服务对应的UUID        手机蓝牙客类服务对应的UUID ServiceDiscoveryServerServiceClassID_UUID = '{00001000-0000-1000-8000-00805F9B34FB}' BrowseGroupDescriptorServiceClassID_UUID = '{00001001-0000-1000-8000-00805F9B34FB}' PublicBrowseGroupServiceClass_UUID = '{.........
    ▪ ListView与Button的共存有关问题解决        ListView与Button的共存问题解决  这些一直在弄来电短信拒接的功能,页面用ListView 来实现在,想在其中加入按钮,加入之后,但按钮点击事件没有反应 =============== public.........
    ▪ 怎么判断SD卡的剩余空间小于某个值       如何判断SD卡的剩余空间小于某个值 这是一个工具类,如果SD卡的剩余空间小于某个值返回false,如果有足够的空间,则返回true。public class SDCardSizeUtil {                public static boolean isAva.........

[1]手机蓝牙客种服务对应的UUID
    来源: 互联网  发布时间: 2014-02-18
手机蓝牙客类服务对应的UUID

ServiceDiscoveryServerServiceClassID_UUID = '{00001000-0000-1000-8000-00805F9B34FB}'
BrowseGroupDescriptorServiceClassID_UUID = '{00001001-0000-1000-8000-00805F9B34FB}'
PublicBrowseGroupServiceClass_UUID = '{00001002-0000-1000-8000-00805F9B34FB}'

#蓝牙串口服务
SerialPortServiceClass_UUID = '{00001101-0000-1000-8000-00805F9B34FB}'

LANAccessUsingPPPServiceClass_UUID = '{00001102-0000-1000-8000-00805F9B34FB}'

#拨号网络服务
DialupNetworkingServiceClass_UUID = '{00001103-0000-1000-8000-00805F9B34FB}'

#信息同步服务
IrMCSyncServiceClass_UUID = '{00001104-0000-1000-8000-00805F9B34FB}'

SDP_OBEXObjectPushServiceClass_UUID = '{00001105-0000-1000-8000-00805F9B34FB}'

#文件传输服务
OBEXFileTransferServiceClass_UUID = '{00001106-0000-1000-8000-00805F9B34FB}'

IrMCSyncCommandServiceClass_UUID = '{00001107-0000-1000-8000-00805F9B34FB}'
SDP_HeadsetServiceClass_UUID = '{00001108-0000-1000-8000-00805F9B34FB}'
CordlessTelephonyServiceClass_UUID = '{00001109-0000-1000-8000-00805F9B34FB}'
SDP_AudioSourceServiceClass_UUID = '{0000110A-0000-1000-8000-00805F9B34FB}'
SDP_AudioSinkServiceClass_UUID = '{0000110B-0000-1000-8000-00805F9B34FB}'
SDP_AVRemoteControlTargetServiceClass_UUID = '{0000110C-0000-1000-8000-00805F9B34FB}'
SDP_AdvancedAudioDistributionServiceClass_UUID = '{0000110D-0000-1000-8000-00805F9B34FB}'
SDP_AVRemoteControlServiceClass_UUID = '{0000110E-0000-1000-8000-00805F9B34FB}'
VideoConferencingServiceClass_UUID = '{0000110F-0000-1000-8000-00805F9B34FB}'
IntercomServiceClass_UUID = '{00001110-0000-1000-8000-00805F9B34FB}'

#蓝牙传真服务
FaxServiceClass_UUID = '{00001111-0000-1000-8000-00805F9B34FB}'

HeadsetAudioGatewayServiceClass_UUID = '{00001112-0000-1000-8000-00805F9B34FB}'
WAPServiceClass_UUID = '{00001113-0000-1000-8000-00805F9B34FB}'
WAPClientServiceClass_UUID = '{00001114-0000-1000-8000-00805F9B34FB}'

#个人局域网服务
PANUServiceClass_UUID = '{00001115-0000-1000-8000-00805F9B34FB}'

#个人局域网服务
NAPServiceClass_UUID = '{00001116-0000-1000-8000-00805F9B34FB}'

#个人局域网服务
GNServiceClass_UUID = '{00001117-0000-1000-8000-00805F9B34FB}'

DirectPrintingServiceClass_UUID = '{00001118-0000-1000-8000-00805F9B34FB}'
ReferencePrintingServiceClass_UUID = '{00001119-0000-1000-8000-00805F9B34FB}'
ImagingServiceClass_UUID = '{0000111A-0000-1000-8000-00805F9B34FB}'
ImagingResponderServiceClass_UUID = '{0000111B-0000-1000-8000-00805F9B34FB}'
ImagingAutomaticArchiveServiceClass_UUID = '{0000111C-0000-1000-8000-00805F9B34FB}'
ImagingReferenceObjectsServiceClass_UUID = '{0000111D-0000-1000-8000-00805F9B34FB}'
SDP_HandsfreeServiceClass_UUID = '{0000111E-0000-1000-8000-00805F9B34FB}'
HandsfreeAudioGatewayServiceClass_UUID = '{0000111F-0000-1000-8000-00805F9B34FB}'
DirectPrintingReferenceObjectsServiceClass_UUID = '{00001120-0000-1000-8000-00805F9B34FB}'
ReflectedUIServiceClass_UUID = '{00001121-0000-1000-8000-00805F9B34FB}'
BasicPringingServiceClass_UUID = '{00001122-0000-1000-8000-00805F9B34FB}'
PrintingStatusServiceClass_UUID = '{00001123-0000-1000-8000-00805F9B34FB}'

#人机输入服务
HumanInterfaceDeviceServiceClass_UUID = '{00001124-0000-1000-8000-00805F9B34FB}'

HardcopyCableReplacementServiceClass_UUID = '{00001125-0000-1000-8000-00805F9B34FB}'

#蓝牙打印服务
HCRPrintServiceClass_UUID = '{00001126-0000-1000-8000-00805F9B34FB}'

HCRScanServiceClass_UUID = '{00001127-0000-1000-8000-00805F9B34FB}'
CommonISDNAccessServiceClass_UUID = '{00001128-0000-1000-8000-00805F9B34FB}'
VideoConferencingGWServiceClass_UUID = '{00001129-0000-1000-8000-00805F9B34FB}'
UDIMTServiceClass_UUID = '{0000112A-0000-1000-8000-00805F9B34FB}'
UDITAServiceClass_UUID = '{0000112B-0000-1000-8000-00805F9B34FB}'
AudioVideoServiceClass_UUID = '{0000112C-0000-1000-8000-00805F9B34FB}'
SIMAccessServiceClass_UUID = '{0000112D-0000-1000-8000-00805F9B34FB}'
PnPInformationServiceClass_UUID = '{00001200-0000-1000-8000-00805F9B34FB}'
GenericNetworkingServiceClass_UUID = '{00001201-0000-1000-8000-00805F9B34FB}'
GenericFileTransferServiceClass_UUID = '{00001202-0000-1000-8000-00805F9B34FB}'
GenericAudioServiceClass_UUID = '{00001203-0000-1000-8000-00805F9B34FB}'
GenericTelephonyServiceClass_UUID = '{00001204-0000-1000-8000-00805F9B34FB}'


    
[2] ListView与Button的共存有关问题解决
    来源: 互联网  发布时间: 2014-02-18
ListView与Button的共存问题解决
 这些一直在弄来电短信拒接的功能,页面用ListView 来实现在,想在其中加入按钮,加入之后,但按钮点击事件没有反应
===============
public class SmsRejectCallView extends ListView
{   
   
    Button imageBtn;
    Resources res = getResources();
   
    SmsRejectClikListener mClickListener;
    String [] mStrings = res.getStringArray(R.array.sms_reject);
    ArrayAdapter<String> mAdapter;
   

    public SmsRejectCallView(Context context)
    {  
        super(context);
        iniList(context);
    } 

    public SmsRejectCallView(Context context, AttributeSet attrs)
    {
        super(context, attrs);
        iniList(context);
    }

    public SmsRejectCallView(Context context, AttributeSet attrs, int defStyle)
    {
        super(context, attrs, defStyle);
        iniList(context);
    }   

    private void iniList(Context context)
    {       
        setOnItemClickListener(mOnClickListener);
        //Add by kylin 2011.09.23 begin
        LayoutParams layoutPrams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        imageBtn = new Button(context);
        imageBtn.setLayoutParams(layoutPrams);
        String imageBtnName =  res.getString(R.string.news_sms);
        imageBtn.setText(imageBtnName);
         imageBtn.setFocusable(false);
        addHeaderView(imageBtn);
        //end
        mAdapter = new ArrayAdapter<String>(context, android.R.layout.simple_list_item_1, mStrings);
        setAdapter(mAdapter);
    }

    private AdapterView.OnItemClickListener mOnClickListener = new AdapterView.OnItemClickListener()
    {
        public void onItemClick(AdapterView<?> parent, View v, int position, long id)
        {
            if (mClickListener == null)
            {
                return;
            }
           
            if (position == 0)
            {
                mClickListener.onClikNewSms();
            }
            else
            {
                String sms = (String)(mAdapter.getItem(position-1));
                mClickListener.onClickSmsItem(sms);
            }
           
        }
    };


    public interface SmsRejectClikListener
    {
        public void onClikNewSms();
        public void onClickSmsItem(String sms);
    }
       
    public void setSmsRejectSelectedListener(SmsRejectClikListener listener)
    {
        mClickListener = listener;
    }

}








这两天在捣鼓ListView widget,为了在ListView中加入Button这类的有 “点击” 事件的widget,请教了不少高手,感谢LandMark对我的认真讲解,下面把解决过程描述一下。
 
ListView 和 其它能触发点击事件的widget无法一起正常工作的原因是加入其它widget后,ListView的itemclick事件将无法触发,被其它widget的click事件屏蔽。
 
  • 首先,说明一下,ListView中每一行包括以下三项:
 
   一个ImageView, 一个TextView,一个ImageButton,依次排开。
 
以下是layout的内容,分为两部分:
  • res/layout/main.xml

 

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

    < ListView android:id= "@id/android:list" android:layout_width= "fill_parent"
        android:layout_height= "fill_parent" / >
< / LinearLayout>

因为继承了ListActivity,所以ListView 的id设置为"@id/android:list"是必须的

  • res/layout/lvitem.xml

注意:

在< RelativeLayout>中

android:descendantFocusability= "blocksDescendants"

和< ImageButton>中

android:focusable = "false"

这两项的设置很关键,如果不设置,将导致ListView的ItemClick事件将无法触发,该事件被ImageButton的click事件屏蔽了。

< ? xml version = "1.0" encoding = "utf-8" ? >
< RelativeLayout
  xmlns:android= "http://schemas.android.com/apk/res/android"
  android:layout_width= "fill_parent"
  android:layout_height= "wrap_content"
  android:padding= "5dip"
  android:descendantFocusability= "blocksDescendants" >
  
  < ImageView
      android:id= "@+id/ItemImage"
    android:layout_width= "wrap_content"
    android:layout_height= "wrap_content"
    android:padding= "5dip"
  / >
  
  
  < !--
      把按钮背景设置为透明:     android:background= "#00000000"
      把按钮背景设置为半透明:     android:background= "#e0000000"
      -->
  < ImageButton
     android:id= "@+id/ItemCloseWin"
     
     android:layout_alignParentRight= "true"
     android:layout_alignTop= "@+id/ItemWinName"
      android:layout_alignBottom= "@+id/ItemWinName"
      android:layout_width= "wrap_content"
      android:layout_height= "wrap_content"
      
      android:background= "#e0000000"
      android:gravity= "left|center_vertical"
      android:focusable= "false"
      android:src= "@android:drawable/ic_menu_close_clear_cancel"
  / >
  
  < TextView
      android:id= "@+id/ItemWinName"
      
      android:layout_toRightOf= "@+id/ItemImage"
      android:layout_toLeftOf= "@+id/ItemCloseWin"
      android:layout_alignTop= "@+id/ItemImage"
      android:layout_alignBottom= "@+id/ItemImage"
      android:layout_width= "wrap_content"
      android:layout_height= "wrap_content"
      
      android:gravity= "left|center_vertical"
      android:textSize= "20dip"
      android:text= "title"
  / >
    
   
< / RelativeLayout>

  • 接下来,我们看看继承ListActivity的实现

在lvWithButtonExt中,为了能处理ImageButton的click事件,我继承了BaseAdapter类,并重新实现了getView()接口,在其中加入了Button的clicklistener,详见 lvButtonAdapter类的实现。

public class lvWithButtonExt extends ListActivity {
    @Override
    protected void onCreate( Bundle savedInstanceState) {
        super . onCreate( savedInstanceState) ;
        setContentView( R. layout . main) ;

        // 关联Layout中的ListView
        ListView vncListView = ( ListView ) findViewById( android. R. id . list ) ;
        
        // 生成动态数组,加入数据 
        ArrayList < HashMap < String , Object > > remoteWindowItem = new ArrayList < HashMap < String , Object > > ( ) ;
        for ( int i= 0; i< 10; i+ + )
        {
            HashMap < String , Object > map = new HashMap < String , Object > ( ) ;
            map . put ( "ItemImage" , R. drawable. firefox) ; //图像资源的ID 
            map . put ( "ItemWinName" , "Window ID " + i) ;
            map . put ( "ItemCloseWin" , android. R. drawable. ic_menu_close_clear_cancel) ;
            remoteWindowItem. add ( map ) ;
        }
        
      // 生成适配器的Item和动态数组对应的元素 
        lvButtonAdapter listItemAdapter = new lvButtonAdapter(
            this ,
            remoteWindowItem, //数据源 
            R. layout . lvitem, //ListItem的XML实现

            //动态数组与ImageItem对应的子项 
            new String [ ] { "ItemImage" , "ItemWinName" , "ItemCloseWin" } ,
            //ImageItem的XML文件里面的一个ImageView,两个TextView ID 
            new int [ ] { R. id . ItemImage, R. id . ItemWinName, R. id . ItemCloseWin}
        ) ;
        
        vncListView. setAdapter( listItemAdapter) ;
    }

    @Override
    protected void onListItemClick( ListView l, View v, int position , long id ) {
        // TODO Auto-generated method stub
        super . onListItemClick( l, v, position , id ) ;
        l. getItemAtPosition( position ) ;
    }
}

  • 接下来,我们看看lvButtonAdapter 的实现

为了响应按钮的点击事件,首先要记录按钮的位置,然后为按钮设置clicklistener。

在重新实现的getView()接口中,我使用了lvButtonListener监听类,在构造函数中,记录行号,以便在OnClick接口中能准确的定位按钮所在的位置,进而对相应的行进行处理。

public class lvButtonAdapter extends BaseAdapter {
    private class buttonViewHolder {
        ImageView appIcon;
        TextView appName;
        ImageButton buttonClose;
    }
    
    private ArrayList < HashMap < String , Object > > mAppList;
    private LayoutInflater mInflater;
    private Context mContext;
    private String [ ] keyString;
    private int [ ] valueViewID;
    private buttonViewHolder holder;
    
    public lvButtonAdapter( Context c, ArrayList < HashMap < String , Object > > appList, int resource,
            String [ ] from , int [ ] to) {
        mAppList = appList;
        mContext = c;
        mInflater = ( LayoutInflater) mContext. getSystemService( Context . LAYOUT_INFLATER_SERVICE) ;
        keyString = new String [ from . length ] ;
        valueViewID = new int [ to. length ] ;
        System . arraycopy ( from , 0, keyString, 0, from . length ) ;
        System . arraycopy ( to, 0, valueViewID, 0, to. length ) ;
    }
    
    @Override
    public int getCount ( ) {
        return mAppList. size ( ) ;
    }

    @Override
    public Object getItem ( int position ) {
        return mAppList. get ( position ) ;
    }

    @Override
    public long getItemId( int position ) {
        return position ;
    }

    public void removeItem ( int position ) {
        mAppList. remove ( position ) ;
        this . notifyDataSetChanged( ) ;
    }
    
    @Override
    public View getView ( int position , View convertView, ViewGroup parent ) {
        if ( convertView ! = null ) {
            holder = ( buttonViewHolder) convertView. getTag ( ) ;
        } else {
            convertView = mInflater. inflate ( R. layout . lvitem, null ) ;
            holder = new buttonViewHolder( ) ;
            holder. appIcon = ( ImageView ) convertView. findViewById( valueViewID[ 0] ) ;
            holder. appName = ( TextView) convertView. findViewById( valueViewID[ 1] ) ;
            holder. buttonClose = ( ImageButton) convertView. findViewById( valueViewID[ 2] ) ;
            convertView. setTag( holder) ;
        }
        
        HashMap < String , Object > appInfo = mAppList. get ( position ) ;
        if ( appInfo ! = null ) {
            String aname = ( String ) appInfo. get ( keyString[ 1] ) ;
            int mid = ( Integer ) appInfo. get ( keyString[ 0] ) ;
            int bid = ( Integer ) appInfo. get ( keyString[ 2] ) ;
            holder. appName. setText ( aname) ;
            holder. appIcon. setImageDrawable( holder. appIcon. getResources ( ) . getDrawable( mid) ) ;
            holder. buttonClose. setImageDrawable( holder. buttonClose. getResources ( ) . getDrawable( bid) ) ;
            holder. buttonClose. setOnClickListener( new lvButtonListener( position ) ) ;
        }         
        return convertView;
    }

    class lvButtonListener implements OnClickListener {
        private int position ;

        lvButtonListener( int pos) {
            position = pos;
        }
        
        @Override
        public void onClick( View v) {
            int vid= v. getId ( ) ;
            if ( vid = = holder. buttonClose. getId ( ) )
                removeItem ( position ) ;
        }
    }
}

 

////////////////////////////////////////

备注1; 对于Android开发来说处理一些界面需要和Adapter适配器打交道,虽然Android自带了一些比如ArrayAdapter但是大多数情况下无法满足我们需要,所以就要从BaseAdapter派生一个类满足我们特殊的需要。

  首先我们可能重写getView(),通过LayoutInflater的inflate方法映射一个自己定义的Layout布局xml加载或从xxxView中创建。这些大家可能滚瓜烂熟了但是仍然很多Android 开发者对于BaseAdapter中notifyDataSetChanged()方法不是很理解,notifyDataSetChanged方法通过一个外部的方法控制如果适配器的内容改变时需要强制调用getView来刷新每个Item的内容。


    
[3] 怎么判断SD卡的剩余空间小于某个值
    来源: 互联网  发布时间: 2014-02-18
如何判断SD卡的剩余空间小于某个值

这是一个工具类,如果SD卡的剩余空间小于某个值返回false,如果有足够的空间,则返回true。
public class SDCardSizeUtil {
        
        public static boolean isAvaiableSpace(int sizeMb){
                boolean ishasSpace = false;
                if(android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)){
                        String sdcard = Environment.getExternalStorageDirectory().getPath(); 
                    StatFs statFs = new StatFs(sdcard); 
                    long blockSize = statFs.getBlockSize();
                    long blocks = statFs.getAvailableBlocks();
                    long availableSpare = (blocks*blockSize)/(1024*1024);
                    Log.d("剩余空间", "availableSpare = " + availableSpare);
                    if(availableSpare > sizeMb){
                            ishasSpace = true;
                    }
                }                    
                return ishasSpace;  
        }
}


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