随笔分类 - Android
摘要:一:需要的效果如下图所示:可以动态设置提醒数,如果提醒数小于1则不显示红色提醒图标。在点击每一个Button时,同时改变字体颜色与背景颜色以及将红色提醒去掉,如下图所示:二:实现原理:通过继承LinearLayout进行扩展,自定义复合控件。在创建复合控件时,必须对他包含的视图布局、外观以及交互进行...
阅读全文
摘要:1:MyServicepublic class MyService extends IntentService{ AlarmManager alarmManager = null; PendingIntent alarmIntent = null; public MySe...
阅读全文
摘要:1:使用 lsusb 命令查看USB 设备y@y:~$ lsusbBus 001 Device 002: ID 8087:8000 Intel Corp. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hubBus 003 De...
阅读全文
摘要:将ADT 解压之后,新建Android工程后没有R文件:google之后说要安装 ia32-libs 提示如下:安装lib32z1安装完成后,再次新建工程,报错如下:编译存在问题:则继续安装以下两个包:#apt-get install g++-multilib#apt-get install lib...
阅读全文
摘要://对EditText注册OnTouch事件etSscxNssbDate.setOnTouchListener(selectDateTouchListener);//选择日期 private OnTouchListener selectDateTouchListener = new OnTou...
阅读全文
摘要:代码案例如下: lvXxsdMore.setOnItemClickListener(xxsdMoreListener); //对listView 注册onclick事件 lvXxsdMore.setOnScrollListener(new WScrollList...
阅读全文
摘要:一:AsyncTask 的使用(1)activity_main.xml (2)MainActivity.javapublic class MainActivity extends Activity { private ProgressBar asyncPb = null; private Te...
阅读全文
摘要:1:GetSmsService.javapublic class GetSmsService extends IntentService{ private AlarmManager alarmManager = null; private PendingIntent alarmIntent = null; public GetSmsService(){ super("WtacService"); } public GetSmsService(String name) { super(name); } @Ove...
阅读全文
摘要:1:定义一个服务类,在服务类中使用AlarmManager 来管理服务的运行public class WtacService extends Service{ private AlarmManager alarmManager = null; private PendingIntent alarmIntent = null; @Override public IBinder onBind(Intent arg0) { return null; } @Override public void onCreate() { ...
阅读全文
摘要:1:MainActivity.javapublic class MainActivity extends Activity { private TextView tvInfo = null; private BroadcastReceiver receiver = null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity...
阅读全文
摘要:把用户输入的内容保存到数据库表中,然后用户输入时,进行模糊查询并把查询结果附到AutoCompleteTextView中。1:activity_main.xml 2:DbUtil.javapackage com.example.autotest;import android.content.Context;import android.database.sqlite.SQLiteDatabase;import android.database.sqlite.SQLiteOpenHelper;public ...
阅读全文
摘要:public class MainActivity extends Activity { private Button btn = null; private List> list = null; private XmlResourceParser xrp = null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activit...
阅读全文
摘要:文件结构如下:assets/info/info AssetManager am = this.getResources().getAssets(); InputStream input = null; try { input = am.open("info/info"); int len = input.available(); byte[] buffer = new byte[len]; input.read(buff...
阅读全文
摘要:定义一个广播接收器public class SMSReceiver extends BroadcastReceiver { private SmsManager smsManager; @Override public void onReceive(Context arg0, Intent intent) { if(intent.getAction().equals("android.provider.Telephony.SMS_RECEIVED")){ SharedPreferences sp = ...
阅读全文
摘要:1:activity_main.xml 2:MainActivity.javapackage com.example.async;import android.os.AsyncTask;import android.os.Bundle;import android.view.View;import android.widget.ProgressBar;import android.widget.TextView;import android.app.Activity;public class MainActivity extends Activity { pri...
阅读全文
摘要:expandableListView.setOnGroupExpandListener(new OnGroupExpandListener(){ @Override public void onGroupExpand(int groupPosition) { //保证每次只展开一组 int count=expandableListView.getExpandableListAdapter().getGroupCount(); for(int i=0;i<coun...
阅读全文
摘要://隐藏输入键盘 ((InputMethodManager)getSystemService(INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(BshToolsActivity.this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
阅读全文
摘要:Theconnectiontoadbisdown,andasevereerrorhasoccured. YoumustrestartadbandEclipse.Pleaseensurethatadbiscorrectlylocatedat ....解决方法:(1):打开CMD,进入:>adt-bundle-windows-x86-20131030\sdk\platform-tools>adb.exe kill-server提示:* server not running *>adt-bundle-windows-x86-20131030\sdk\platform-tools&g
阅读全文
摘要://将点击时的背景色设置为透明 gridView.setSelector(new ColorDrawable(Color.TRANSPARENT));此时点击GridView的每个Item就不会出现难看的背景色了。为了有更好的用户体验,可以对每个Item添加动画:gridView.setOnItemClickListener(new ItemClickListener());此时点击Item时,图标就会有变化:private class ItemClickListener implements OnItemClickListener{ @Override ...
阅读全文
摘要:在对应的Activity中设置:android:windowSoftInputMode="adjustUnspecified|stateHidden"
阅读全文