锘??xml version="1.0" encoding="utf-8" standalone="yes"?> 鍦╠rawable鐩綍涓嬪垱寤轟竴涓猺epeat_bg.xml: src鏄紩鐢ㄥ浘鐗囩殑鍚嶇О 鐒跺悗鍦ㄥ竷灞鐨剎ml鏂囦歡涓彲浠ヨ繖鏍峰紩鐢? 鍓嶈█ 銆銆鏈珷鍐呭鏄痑ndroid.widget.CompoundButton錛岀炕璇戞潵鑷痙緗楀痙錛屽啀嬈℃劅璋㈠痙緗楀痙 錛佹湡寰呬綘涓璧峰弬涓嶢ndroid API 鐨勪腑鏂囩炕璇戯紝鑱旂郴鎴憃ver140@gmail.com銆?span class="Apple-converted-space"> 杞澆 姝f枃 銆銆涓銆佺粨鏋?/p>
銆銆銆銆public abstract class CompoundButton extends Button implements Checkable 銆銆浜屻佹榪?/p>
銆銆銆銆涓涓甫鏈夐変腑/鏈変腑鐘舵佺殑鎸夐挳銆傚綋鎸夐挳鎸変笅鎴栫偣涓椂鑷姩鏀瑰彉鐘舵併?/span> 銆銆涓夈佸叕鍏辨柟娉?/p>
public boolean dispatchPopulateAccessibilityEvent (AccessibilityEvent event) 鍦ㄥ瓙瑙嗗浘鐨勬瀯寤烘椂鍒嗘淳涓涓緟鍔╀簨浠躲傦紙璇戣呮敞錛氶氳繃婧愮爜鍙互鐪嬪嚭錛岃鍥炬瀯寤烘椂璁劇疆鍏墮変腑鐘舵併傦級 鍙傛暟 event 浜嬩歡 榪斿洖鍊?/span> 濡傛灉浜嬩歡鍏ㄩ儴瀹屾垚榪斿洖True銆?/span> public boolean isChecked () 錛堣瘧鑰呮敞錛氭槸鍚﹂変腑錛?/span> public void onRestoreInstanceState (Parcelable state) 鍏佽瑙嗗浘閲嶆柊搴旂敤浠ュ墠閫氳繃onSaveInstanceState()鐢熸垚浠h〃鍐呴儴鐨勭姸鎬併傝繖涓嚱鏁板喅涓嶈皟鐢ㄤ竴涓┖鐨勭姸鎬併?/span> 鍙傛暟 state 榪斿洖浠ュ墠璋冪敤onSaveInstanceState()淇濆瓨涓嬫潵鐨勭姸鎬併?/span> public Parcelable onSaveInstanceState () 鍏佽瑙嗗浘鐢熸垚涓涓唬琛ㄥ唴閮ㄧ殑鐘舵侊紝浠ュ悗鍙敤浜庡垱寤轟竴涓笌涔嬬浉鍚岀殑鏂扮殑瀹炰緥銆傝繖縐嶇姸鎬佸簲璇ュ彧鍖呭惈闈炴寔涔呮垨浠ュ悗涓嶈兘澶熼噸寤虹殑淇℃伅銆備緥濡傦紝浣犲喅涓嶅瓨鍌ㄤ綘褰撳墠鍦ㄥ睆騫曚笂鐨勪綅緗紝鍥犱負榪欎細鍦ㄨ鍥劇殑灞傞潰涓婇噸鏂拌綆楁斁緗竴涓柊鐨勫疄渚嬨?/span> 浣犲彲浠ュ瓨鍌ㄥ埌榪欓噷鐨勪竴浜涗緥瀛愶細涓涓枃鏈涓綋鍓嶅厜鏍囩殑浣嶇疆錛堜絾閫氬父涓嶆槸鏂囧瓧鏈韓錛屾枃瀛楅氬父淇濆瓨鍦ㄥ唴瀹規彁渚涜?/span>(content provider)鎴栧叾浠栨寔涔呯殑鍌ㄥ瓨涓級錛屼竴涓垪琛ㄨ鍥句腑鐨勫綋鍓嶉変腑欏廣?/span> 榪斿洖鍊?/span> 榪斿洖涓涓寘鍚鍥懼綋鍓嶇姸鎬佺殑Parcelable瀵硅薄錛屾垨娌℃湁浠涔堢姸鎬佷繚瀛樻椂榪斿洖null銆傞粯璁ゅ疄鐜拌繑鍥?/span>null銆?/span> public boolean performClick () 濡傛灉瑙嗗浘瀹氫箟浜?/span>OnClickListener鐩戝惉鍣紝璋冪敤姝ゆ柟娉曟潵鎵ц銆?/span> 榪斿洖鍊?/span> 瀹氫箟浜嗙殑OnClickListener琚皟鐢ㄨ繑鍥?/span>True錛屽惁鍒欒繑鍥?/span>False public void setButtonDrawable (Drawable d) 緇欐寜閽儗鏅緗竴涓彲緇樺埗瀵硅薄錛堝錛氬浘鍍忥級 鍙傛暟 d 鐢ㄤ綔鑳屾櫙鐨勫彲緇樺埗瀵硅薄錛堝錛氬浘鍍忥級 public void setButtonDrawable (int resid) 閫氳繃璧勬簮Id緇欐寜閽儗鏅緗竴涓浘鍍?/span> 鍙傛暟 resid 浣滀負鑳屾櫙鍥懼儚鐨勮祫婧?/span>id public void setChecked (boolean checked) 鏀瑰彉鎸夐挳鐨勯変腑鐘舵?/span> 鍙傛暟 checked true閫変腑錛?/span>false闈為変腑 public void setOnCheckedChangeListener (CompoundButton.OnCheckedChangeListener listener) 娉ㄥ唽涓涓湪鎸夐挳鐘舵佸彂鐢熸敼鍙樻椂鎵ц鐨勫洖璋冨嚱鏁?/span> 鍙傛暟 listener 褰撻変腑鐘舵佹敼鍙樻椂璋冪敤鐨勫嚱鏁?/span> public void toggle () 鏀瑰彉閫変腑鐘舵佷負褰撳墠鐘舵佺殑閫嗙姸鎬?/span> 銆銆鍥涖佸彈淇濇姢鏂規硶 protected void drawableStateChanged () 鍦ㄨ鍥劇姸鎬佺殑鍙樺寲褰卞搷鍒版墍鏄劇ず鍙粯鍒剁殑鐘舵佹椂璋冪敤榪欎釜鏂規硶銆?/span> 紜繚鍦ㄩ噸杞芥椂涓皟鐢ㄧ埗綾繪柟娉?/span> protected int[] onCreateDrawableState (int extraSpace) 涓哄綋鍓嶈鍥劇敓鎴愭柊鐨勫彲緇樺浘鍖虹姸鎬併傝繖涓柟寮忓綋緙撳瓨鐨勫浘鍍忕粯鍥懼尯鐘舵佺‘瀹氬け鏁堟椂閫氳繃瑙嗗浘緋葷粺璋冪敤銆備綘鍙互浣跨敤getDrawableState()鏂規硶閲嶆柊鍙栧緱褰撳墠鐨勭姸鎬併?/span> 鍙傛暟 extraSpace 濡傛灉涓洪潪闆訛紝榪欐槸浣犲簲璇ヨ繑鍥炵殑鏁扮粍鍦ㄤ綘鍙互瀛樻斁浣犵殑鐘舵佺殑棰濆鏉$洰鐨勬暟閲忋?/span> 榪斿洖鍊?/span> 榪斿洖涓涓褰曠潃瑙嗗浘涓綋鍓嶇粯鍥懼尯鐘舵佺殑鏁扮粍 protected void onDraw (Canvas canvas) 瀹炵幇浣犺嚜宸辯殑緇樺埗銆?/span> 鍙傛暟 canvas 鍦ㄧ敾甯冧笂緇樺埗鑳屾櫙 protected boolean verifyDrawable (Drawable who) 濡傛灉浣犵殑瑙嗗浘瀛愮被鏄劇ず浠栬嚜宸辯殑鍙鍖栧璞★紝浠栧皢瑕侀噸鍐欐鏂規硶騫朵笖涓轟簡鏄劇ず鍙粯鍒惰繑鍥?/span>true銆傛鎿嶄綔鍏佽榪涜緇樺埗鏃舵湁鍔ㄧ敾鏁堟灉銆?/span> 銆銆紜褰撻噸鍐欎粠鏂規硶鏃訛紝闇璋冪敤鐖剁被鐩稿簲鏂規硶銆?/span> 鍙傛暟 who 闇鍒ゆ柇鐨勫彲緇樺埗瀵硅薄錛?/span>Drawable錛夈傚鏋滄槸浣犺鏄劇ず鐨勫璞★紝榪斿洖True錛屽惁鍒欒繑鍥炶皟鐢ㄧ埗綾葷殑緇撴灉銆?/span> 榪斿洖鍊?/span>
]]>
]]>
]]>
1
<LinearLayout android:layout_width=
"fill_parent"
2
android:layout_height=
"fill_parent"
3
android:background=
"@drawable/repeat_bg"
>
4
</LinearLayout>
]]>
銆銆銆銆銆銆android.view.View
銆銆銆銆銆銆銆銆android.widget.TextView
銆銆銆銆銆銆銆銆銆銆android.widget.Button
銆銆銆銆銆銆銆銆銆銆銆銆android.widget.CompoundButton
]]>android library projects cannot be launched
]]>
activity_main.xml
<LinearLayout xmlns:android=" xmlns:tools=" xmlns:android1=" android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView
android1:id="@+id/listView1"
android1:layout_width="match_parent"
android1:layout_height="wrap_content"
android1:layout_weight="1" >
</ListView>
</LinearLayout>
list_item.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=" android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="center_vertical"
android:id="@+id/waibubuju"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/bianhao"
android:text="緙栧彿"
android:textColor="#88ff0000"
android:gravity="center"
android:textSize="18sp"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/neibubuju"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="濮撳悕"
android:id="@+id/username"
/>
MainActivity.java
package com.hyl.listViewpack;
import java.util.ArrayList;
import android.R.string;
import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Adapter;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.ScrollView;
import android.widget.TextView;
public class MainActivity extends Activity {
protected static final String TAG = "MainActivity";
private ListView listView1;
ArrayList<ArrayList<String>> arr ;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
listView1=(ListView) findViewById(R.id.listView1);
arr=new ArrayList<ArrayList<String>>();
for(int i=0;i<=50;i++){
ArrayList<String> a=new ArrayList<String>();
a.add("緙栧彿錛?+i);
a.add("濮撳悕錛?+i);
a.add("鐢佃瘽錛?+i);
arr.add(a);
}
listView1.setAdapter(new BaseAdapter() {
public View getView(int position, View convertView, ViewGroup parent) {
//鐖剁獥浣?鎸傝澆
View view=View.inflate(MainActivity.this, R.layout.list_item, null);
Log.e(TAG, "嫻嬭瘯鍒涘緩瀵硅薄浣嶇疆錛?+position);
ArrayList<String> a=arr.get(position);
TextView tvbianhao=(TextView) view.findViewById(R.id.bianhao);
tvbianhao.setText( a.get(0));
TextView tvUserName=(TextView) view.findViewById(R.id.username);
tvUserName.setText( a.get(1));
TextView tvTel=(TextView) view.findViewById(R.id.tel);
tvTel.setText( a.get(2));
return view;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return null;
}
@Override
public int getCount() {
return arr.size();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="鐢佃瘽"
android:id="@+id/tel"
/>
</LinearLayout>
</LinearLayout>
ArrayAdapter鏂瑰紡
//涓婁笅鏂囧璞?nbsp; 甯冨眬鍒楄〃瀵硅薄 鏄劇ず鐨凾extView鐨処D 鏁扮粍瀵硅薄
listView1.setAdapter(new ArrayAdapter<String>(this, R.layout.list_item, R.id.bianhao, new String[]{"閫夐」涓","閫夐」浜?,"閫夐」涓?,"閫夐」鍥?,"閫夐」浜?}));
SimpleAdapter鏂瑰紡
listView1=(ListView) findViewById(R.id.listView1);
ArrayList<Map<String, Object>> list=new ArrayList<Map<String,Object>>();
Map<String, Object> map1=new HashMap<String, Object>();
map1.put("icon", R.drawable.ic1);
map1.put("name", "鍔熻兘涓");
list.add(map1);
Map<String, Object> map2=new HashMap<String, Object>();
map2.put("icon", R.drawable.ic2);
map2.put("name", "鍔熻兘浜?);
list.add(map2);
Map<String, Object> map3=new HashMap<String, Object>();
map3.put("icon", R.drawable.ic3);
map3.put("name", "鍔熻兘涓?);
list.add(map3);
Map<String, Object> map4=new HashMap<String, Object>();
map4.put("icon", R.drawable.ic1);
map4.put("name", "鍔熻兘鍥?);
list.add(map4);
Map<String, Object> map5=new HashMap<String, Object>();
map4.put("icon", R.drawable.ic5);
map4.put("name", "鍔熻兘浜?);
list.add(map5);
listView1.setAdapter(new SimpleAdapter(this, list, R.layout.list_item, new String[]{"icon","name"},new int[]{R.id.tubiao,R.id.gongneng} ));
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_show_list_activy);
lv_show_view = (ListView) findViewById(R.id.lv_show_view);
AsyncHttpClient client=new AsyncHttpClient();
String url = " + "嫻嬭瘯鏂規硶";
client.get(url, new AsyncHttpResponseHandler() {
public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
List<Video> list=new ArrayList<Video>();
try {
Toast.makeText(ShowListActivy.this,statusCode+"", 1).show();
String json = new String(responseBody);
JSONArray array = new JSONArray(json);
for(int i=0 ; i < array.length() ; i++){
JSONObject item= array.getJSONObject(i);
String id = item.getString("id");
String title = item.getString("title");
String timelength = item.getString("time");
Log.e("jsonget", id+title+timelength);
list.add(new Video( id, title, Integer.parseInt(timelength)));
}
List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
for (Video v : list) {
Map<String, Object> it = new HashMap<String, Object>();
it.put("id", v.getId());
it.put("title", v.getTitle());
it.put("timelength", v.getTime());
data.add(it);
}
SimpleAdapter adapter = new SimpleAdapter(ShowListActivy.this, data,R.layout.item, new String[] { "title", "timelength" },new int[] { R.id.title, R.id.timelength });
lv_show_view.setAdapter(adapter);
} catch ( Exception e) {
Log.e("MainActivity", e.toString());
}
}
public void onFailure(int statusCode, Header[] headers,
byte[] responseBody, Throwable error) {
Toast.makeText(ShowListActivy.this,"shibai", 1).show();
}
});
鏄劇ず鍑轟紶榪囨潵鐨刯son緇撴灉錛?br />
鏈枃绔犲彧鏄嚜宸卞涔犵瑪璁幫紝澶у瑕佹厧閲嶅熼壌
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=" package="com.hyl.phone" android:versionCode="1" android:versionName="1.0">
<application android:icon="@drawable/maolv" android:label="@string/app_name">
<activity android:name=".phoneActivity" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<!-- 寮鍙戠殑搴旂敤閫傚簲鐨勭増鏈?浠h〃Android2.2 -->
<uses-sdk android:minSdkVersion="8" />
<!-- 榪欓噷鎸囧畾鎷ㄦ墦鐢佃瘽鐨勬潈闄?-->
<uses-permission android:name="android.permission.CALL_PHONE" />
</manifest>
hyl.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="mobellabel">璇瘋緭鍏ユ墜鏈哄彿鐮?lt;/string>
<string name="button">鎷ㄦ墦姝ゅ彿鐮?lt;/string>
</resources>
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=" android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/mobellabel"
android:id="@+id/TextView01"
/>
<EditText android:id="@+id/EditText01"
android:layout_width="fill_parent" android:layout_height="wrap_content" />
<Button android:text="@string/button" android:id="@+id/Button01"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
phoneActivity.java
package com.hyl.phone;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class phoneActivity extends Activity {
/** Called when the activity is first created. */
private Button button;
private EditText editText;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button= (Button)this.findViewById(R.id.Button01);
editText=(EditText) this.findViewById(R.id.EditText01);
button.setOnClickListener(new ButtonListener());
}
private final class ButtonListener implements View.OnClickListener{
public void onClick(View v) {
String phonenum=editText.getText().toString();
//android.intent.action.CALL=Intent.ACTION_CALL
Intent intent=new Intent(Intent.ACTION_CALL,Uri.parse("tel:"+phonenum));
startActivity(intent);
}
}
}