work hard work smart

专注于Java后端开发。 不断总结,举一反三。
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

随笔分类 -  S.Android

摘要:将android:screenOrientation="portrait",转换横屏竖屏无效,始终显示竖屏。 <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:screenOrientation=" 阅读全文

posted @ 2013-03-28 11:12 work hard work smart 阅读(420) 评论(0) 推荐(0)

摘要:Android 文件操作操作时,要赋予相应的权限: <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>下面是向文件写文本的代码: private final static String PATH = "/sdcard/lin"; private final static String FILENAME = "/test.txt"; @Override protected void onCreate(Bundle savedI 阅读全文

posted @ 2013-03-28 09:55 work hard work smart 阅读(232) 评论(0) 推荐(0)

摘要:原文链接:http://coolxing.iteye.com/blog/1211403 原文地址什么是JSON:JSON即JavaScript Object Natation, 它是一种轻量级的数据交换格式, 与XML一样, 是广泛被采用的客户端和服务端交互的解决方案.JSON对象: JSON中对象(Object)以"{"开始, 以"}"结束. 对象中的每一个item都是一个key-value对, 表现为"key:value"的形式, key-value对之间使用逗号分隔. 如:{"name":"cool 阅读全文

posted @ 2013-03-27 20:05 work hard work smart 阅读(431) 评论(0) 推荐(0)

摘要:Android中ExpandableList的使用2本文介绍Android中ExpandableList的使用,在前文的基础上作了很多改进,增加了增加、删除、回调等功能。图中的 “第一行班组号: 1 软件工程2班”是要显示的信息。先看效果图:首先定义一个含有ExpandableListView的Layout。还有一个是显示的文本信息。<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com 阅读全文

posted @ 2013-03-25 16:42 work hard work smart 阅读(1215) 评论(0) 推荐(0)

摘要:Android ExpandableListView的使用一、MainActivity要继承ExpandableListActivity。效果是当单机ListView的子项是显示另一个ListView。public class MainActivity extends ExpandableListActivity { private static final String NAME = "NAME"; private static final String IS_EVEN = "IS_EVEN"; private ExpandableListAdapte 阅读全文

posted @ 2013-03-25 10:40 work hard work smart 阅读(1627) 评论(0) 推荐(0)

摘要:Android 资源的使用一、dimension资源的使用Android中dimension单位有: px 像素 dp 密度mm 毫米 pt 点sp 刻度in英寸dimension资源的定义<resources> <!-- Default screen margins, per the Android Design guidelines. --> <dimen name="activity_horizontal_margin">16dp</dimen> <dimen name="activity_vertica 阅读全文

posted @ 2013-03-21 14:55 work hard work smart 阅读(380) 评论(0) 推荐(0)

摘要:Android 自定义View为MyCustomView。在MyCustomView画了一个Rect,颜色为Green,和一个为红色的文字。public class MyCustomView extends View{ private Paint mPaint; private Context mContext; private static final String mString = "Hello world!"; public MyCustomView(Context context) { super(context); // TODO Auto-ge... 阅读全文

posted @ 2013-03-18 15:59 work hard work smart 阅读(329) 评论(0) 推荐(0)

摘要:Android中的TableLayout的简单使用在Layout中加入TableLayout控件。 <TableLayout android:id="@+id/myTableLayout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="40dp" android:layout_marginTop="157dp" > </Tab 阅读全文

posted @ 2013-03-18 15:22 work hard work smart 阅读(899) 评论(0) 推荐(0)

摘要:项目的结构首先新建一个book_info.xml的xml文件,结构如下:<?xml version="1.0" encoding="UTF-8"?><books> <catalog>Computer</catalog> <book> <country>USA</country> <title>Empire Burlesque</title> <artist>Bob Dylan</artist> <price>10 阅读全文

posted @ 2013-03-18 14:58 work hard work smart 阅读(247) 评论(0) 推荐(0)

摘要:一、Android Notication的使用 private void sendNotification() { // TODO Auto-generated method stub NotificationManager manager = (NotificationManager)this... 阅读全文

posted @ 2013-03-17 21:10 work hard work smart 阅读(945) 评论(0) 推荐(0)

摘要:Layout的设计,其实有我这里直接拖了一个TabHost控件,然后在每个Tab中放一个Button。文件名为activity_tab_host.xml.<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="matc 阅读全文

posted @ 2013-03-16 18:25 work hard work smart 阅读(1178) 评论(0) 推荐(0)

摘要:Android TabHost的使用,这里采用继承TabActivity的方法。这里分别定制三个Tab,分别为american.xml, chinese.xml, japanese.xml三个Layout。american.xml文件 chinese.xml文件 japanese.xml文件 三个Layout对应的java文件为AmericanActivity.java, ChinaActivity.java, JapanActivity.javaAmericanActivity.java文件public clas... 阅读全文

posted @ 2013-03-16 17:35 work hard work smart 阅读(543) 评论(0) 推荐(0)

摘要:Android 中PopupWindow使用。PopupWindow会阻塞对话框,要在外部线程 或者 PopupWindow本身做退出才行。mypopWindow.xml的Layout设计如下。<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android: 阅读全文

posted @ 2013-03-15 14:47 work hard work smart 阅读(21710) 评论(0) 推荐(0)

摘要:1、定义简单的适配器形式。首先定义一个Layout为listviewitem.xml. 里面有三个TextView。分别代表学号,姓名,班级。<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/cuslistViewItem" android:layout_width="match_pa 阅读全文

posted @ 2013-03-14 19:07 work hard work smart 阅读(378) 评论(0) 推荐(0)

摘要:Android 中AlterDialog使用,AlterDialog的使用分为两种,一种是直接使用,一种是自己设计一个Layout,然后当做Dialog显示出来。1、定义两个Button,一个用来显示AlterDialog,一个显示自定义的AlterDialog。 private Button bt1; private Button bt2;注册事件 protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity.. 阅读全文

posted @ 2013-03-14 16:27 work hard work smart 阅读(6511) 评论(0) 推荐(0)

摘要:Android中BroadcastReceiver使用分为动态注册BroastcastReceiver ,静态注册BroastcastReceiver1、动态注册BroastcastReceiver。定义BroadcastReceiver: private BroadcastReceiver bcr1 = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { // TODO Auto-generated meth... 阅读全文

posted @ 2013-03-14 15:19 work hard work smart 阅读(1849) 评论(0) 推荐(0)

摘要:Android 中的Theme和Style使用,还是比较简单的。1、 首先在res/values/styles.xml的resource中定义三个样式,分别为: <style name="TextView"> <item name="android:textSize">38sp</item> <item name="android:textColor">#128</item> <item name="android:shadowRadius"> 阅读全文

posted @ 2013-03-14 13:14 work hard work smart 阅读(3168) 评论(0) 推荐(0)

摘要:Android的Handler使用如何每隔一段时间进行一些操作呢,Handler就可以做到。 下面的Demo的功能为每隔3秒显示MyItems数组中的不同数据。public class MainActivity extends Activity { private int count = 0; private static final String[] MyItems = { "Here is a Item1", "Here is a Item2", "Here is a Item3", "Here is a Item4&q 阅读全文

posted @ 2013-03-14 10:45 work hard work smart 阅读(450) 评论(0) 推荐(0)

摘要:Android 中SharedPreferences使用一、SharedPreferences使用1 protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); SharedPreferences mPerferences = PreferenceManager.getDefaultSharedPreferences(this); int counter = mPerferences... 阅读全文

posted @ 2013-03-14 10:16 work hard work smart 阅读(296) 评论(0) 推荐(0)

摘要:声明:eoe文章著作权属于作者,受法律保护,转载时请务必以超链接形式附带如下信息原文作者: Android_Tutor原文地址: http://my.eoe.cn/androidtutor/archive/1327.html大家好我们这一节讲的是LayoutInflater的使用,在实际开发种LayoutInflater这个类还是非常有用的,它的作用类似于 findViewById()不同点是LayoutInflater是用来找layout下xml布局文件,并且实例化!而findViewById()是找具体xml下的具体 widget控件(如:Button,TextView等)。为了让大家容易 阅读全文

posted @ 2013-03-13 19:38 work hard work smart 阅读(258) 评论(0) 推荐(0)