編輯:關於Android編程
直接上代碼把,主要是重新給item measure高度,直接上代碼把
import java.util.ArrayList; import android.app.Activity; import android.os.Bundle; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.View.OnTouchListener; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ArrayAdapter; import android.widget.BaseAdapter; import android.widget.Button; import android.widget.ListView; import android.widget.RelativeLayout; import android.widget.TextView; public class MainActivity extends Activity { private ArrayListmyList = new ArrayList (); private myAdapter myAdapter; private LayoutInflater inflater = null; private int oldPostion = -1; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final ListView list = (ListView) findViewById(R.id.draggable_list); MyData data = new MyData(); data.name = "11"; myList.add(data); data = new MyData(); data.name = "22"; myList.add(data); data = new MyData(); data.name = "33"; myList.add(data); data = new MyData(); data.name = "44"; myList.add(data); data = new MyData(); data.name = "55"; myList.add(data); data = new MyData(); data.name = "66"; myList.add(data); data = new MyData(); data.name = "77"; myList.add(data); inflater = LayoutInflater.from(this); TextView header = (TextView)inflater.inflate(R.layout.header, null); TextView footer = (TextView)inflater.inflate(R.layout.footer, null); //list.addFooterView(footer); //list.addHeaderView(header); myAdapter = new myAdapter(); list.setAdapter(myAdapter); list.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView> parent, View view, int position, long id) { MyData data = myList.get(position); if (oldPostion == position) { if (data.expand) { oldPostion = -1; } data.expand = !data.expand; }else{ oldPostion = position; data.expand = true; } int totalHeight = 0; for(int i=0;i
Layout:效果圖:
代碼:http://download.csdn.net/detail/baidu_nod/7765251
前一章我們學習了FM的自動調頻,接下來我們就看看FM手動調頻是如何進行的。如果不清楚FM自動調頻的過程,請打開超鏈接查看FM搜索頻率流程。 首先來看一下流程圖: 2.滑
近期項目中需要使用到一種類似手機電池充電進度的動畫效果,以前沒學屬性動畫的時候,是用圖片+定時器的方式來完成的,最近一直在學習動畫這一塊,再加上復習一下自定義view的相
分析android Activity啟動流程中ActivityManagerService所扮演的角色一、概述上一篇文章startActivit
主要講解Android Studio中生成aar文件以及本地方式使用aar文件的方法。 在Android Studio中對一個自己庫進行生成操作時將會同時生成*.jar與