`
文章列表

android一些技巧

EditText ed = new EditText(this); Editable eb = ed.getEditableText(); //获取光标位置 int position = ed.getSelectionStart(); //指定位置插入字符 eb.insert(position, "XXX"); //插入图片 //定义图片所占字节数(“Tag”的长度) Spannab ...
package com.cm; import java.util.ArrayList; import android.R.color; import android.app.Activity; import android.content.Context; import android.graphics.Color; import android.os.Bundle; import android.text.Html; import android.text.Spannable; import android.text.SpannableStringBuilder; ...
转载:http://my.oschina.net/javagg/blog/27834   一、[Android实例]实现TextView里的文字有不同颜色 转eoe:http://www.eoeandroid.com/thread-4496-1-1.html import android.text.Html;TextView t3 = (TextView) findViewById(R.id.text3);        t3.setText(            Html.fromHtml(                "<b>text3:</b&g ...
设置EditText显示或隐藏密码. 在CheckBox的onCheckedChanged()方法中, 判断是否选中. Java代码 if (isChecked) { System.out.println("checked"); // 显示密码 password_edit.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); } else { System.out.println("not checked"); // 隐藏密码 password_edit.setInp ...

list如何remove

    博客分类:
  • Java
在java中对list进行操作很频繁,特别是进行list启遍历,这些操作我们都会,也很熟悉,但是对java中list进行删除元素,remove list中的元素就不怎么熟悉了吧,可以说很陌生,是实际操作中也很容易出错,先看看下面这个java中如何remove list 中的元素吧. public class test { public static void main(String[] args) { String str1 = new String("abcde"); String str2 = new String("abcde&qu ...
1 import java.io.File; 2 import android.app.Activity; 3 import android.content.Intent; 4 import android.graphics.drawable.Drawable; 5 import android.net.Uri; 6 import android.os.Bundle; 7 import android.view.View; 8 import android.view.View.OnClickListener; 9 import android.widget.Button;10 11 public ...

Android 复制 粘贴

Android 复制 粘贴 ClipboardManager clip = (ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE);clip.getText();    // 粘贴clip.setText(str); // 复制
    JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式。易于人阅读和编写。同时也易于机器解析和生成。它基于JavaScript Programming Language, Standard ECMA-262 3rd Edition – December 1999的一个子集。 JSON采用完全独立于语言的文本格式,但是也使用了类似于C语言家族的习惯(包括C, C++, C#, Java, JavaScript, Perl, Python等)。这些特性使JSON成为理想的数据交换语言。     在使用struts2 json plugin的把相关的数据 ...
调用其他程序可以直接使用ComponentName,但有些需要调用Action才行   //可以正常打开 Intent intent=new Intent();    intent.setComponent(new ComponentName("com.android.mms", "com.android.mms.ui.ConversationList"));      M.this.startActivity(intent);     //调用照相机下面会报错: Intent intent=new Intent();intent.setCo ...
Android Dialog 创建对话框 一个对话框一般是一个出现在当前Activity之上的一个小窗口. 处于下面的Activity失去焦点, 对话框接受所有的用户交互. 对话框一般用于提示信息和与当前应用程序直接相关的小功能. Android API 支持下列类 ...
android调用系统程序 1.从google搜索内容 Intent intent = new Intent(); intent.setAction(Intent.ACTION_WEB_SEARCH); intent.putExtra(SearchManager.QUERY,"searchString") startActivity(intent);   2.浏览网页 Uri uri =Uri.parse("http://www.
Android程序使用代码的安装和卸载 安装: String str = "/CanavaCancel.apk"; String fileName = Environment.getExternalStorageDirectory() + str; Intent intent = new Intent(Intent.ACTION_VIEW);  intent.setDataAndType(Uri.fromFile(new File(fileName)), "application/vnd.android.package-archive ...
package lee.HttpClientDemo; import java.io.InputStream; import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.params.BasicHttpParams; import org.apache.http.params.HttpConnectionParams; ...
HttpURLConnection对象 1.从Internet获取网页,发送请求,将网页以流的形式读回来. 步骤:1)创建一个URL对象:URL url = new URL(http://www.baidu.com ); 2)利用HttpURLConnection对象从网络中获取网页数据:HttpURLConnection conn = (HttpURLConnection) url.openConnection();3)设置连接超时:conn.setConnectTimeout(6*1000); 4)对响应码进行判断:if (conn.getResponseCode() != 200) ...
Intent.ACTION_AIRPLANE_MODE_CHANGED; //关闭或打开飞行模式时的广播   Intent.ACTION_BATTERY_CHANGED; //充电状态,或者电池的电量发生变化 //电池的充电状态、电荷级别改变,不能通过组建声明接收这个广播,只有通过Context.registerReceiver()注册   Intent.ACTION_BATTERY_LOW; //表示电池电量低   Intent.ACTION_BATTERY_OKAY; //表示电池电量充足,即从电池电量低变化到饱满时会发出广播   Intent.ACTION_BOO ...
Global site tag (gtag.js) - Google Analytics