1. android listview內使用進度條亂序問題
首先判斷首位不是"-",再判斷字元串中沒有小數點"."
滿足這兩個就是正整數 C語言中 變數都是先聲明再使用,你聲明成INT就是整型,關於正負就判斷一下!
2. android 如何讓listview 里的內容從左到右排列
可以用gallery或者水平滾動的ScrollView,不一定非要用ListView的
3. android listview 多個item 倒計時怎麼做好
Handler+Timer+TimerTask實現: Activity中代碼: public class ShopActivity extends Activity { private ListView lv; private ShopAdapter pmAdapter; private Timer timer = new Timer(); private TimerTask timerTask; private List<MyData> dataList; @SuppressLint("HandlerLeak") private Handler mHandler = new Handler() { public void handleMessage(android.os.Message msg) { if (msg.what == 1) { for (int i = 0; i < mMyMatchList.size(); i++) { dataList.get(i).setServerDate(Long.valueOf(dataList.get(i).getServerDate())+ 1 + "");//這是伺服器當前時間,以此時間為基數進行倒時計,因為伺服器時間以秒為單位返回,所以咱們每隔1秒,把當前伺服器時間+1,也可以把結束時間-1 serverTime = Long.valueOf(mMyMatchList.get(i).getServerDate()); pmAdapter.notifyDataSetChanged(); } } } }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layout_shop); dataList=new ArrayList<MyData>();//接下來要從服務端取到數據,加入dataList中 lv= (ListView) this.findViewById(R.id.shop_lv); pmAdapter = new ShopAdapter(ShopActivity.this, this); lv.setAdapter(pmAdapter); timerTask = new TimerTask() { @Override public void run() { Message message = Message.obtain(); message.what = 1; mHandler.sendMessage(message); } }; timer.schele(timerTask, 1000, 1000); } @Override protected void onResume() { super.onResume(); } @Override protected void onDestroy() { if (null != timer) { timer.cancel(); } super.onDestroy(); } } 最後在適配器類ShopAdapter中,根據伺服器返回的截止時間和伺服器時間,把數據加上去就可以了: TextView timeTv=findViewById(); timeTv.setText(getTimeFromInt(結束時間-伺服器時間)); getTimeFromInt這個方法是計算時間差並轉換成所需要格式的: public String getTimeFromInt(long time) { if (time <= 0) { return "已結束"; } long day = time / (1 * 60 * 60 * 24); long hour = time / (1 * 60 * 60) % 24; long minute = time / (1 * 60) % 60; long second = time / (1) % 60; return "還剩:" + day + "天" + hour + "小時" + minute + "分" + second + "秒"; }
4. 安卓開發,SQLLite中,把數據顯示到listview時候,怎麼進行排序顯示
SQL語句里有個排序的方法 order by 可以根據你資料庫里的一些欄位進行排列。要倒序的話就在欄位名後面加 desc
5. 安卓listview的內容順序問題
這個很簡單啊
首先listview中的item的布局先按照你的順序和設計需求寫好4個textview
然後把收到的數據分別載入到這個item裡面的textview就好了啊
6. android listView動態添加 順序錯亂
你用的集合是不是鍵值對的集合?如果是的話就不是根據你輸入的時間保存的數據。
7. 安卓中怎麼實現listview 條目拖動排序
SlideAndDragListView,可排序、可滑動item顯示」菜單」的ListView。
SlideAndDragListView(SDLV)繼承於Android的ListView,SDLV可以拖動item到SDLV的任意位置,其中包括了拖動item往上滑和往下滑;SDLV可以向右滑動item,像Android的QQ那樣(QQ是向左滑),然後顯現出來"菜單」之類的按鈕。
8. Android 如何按時間先後顯示ListView數據
解決方法:
lisrview綁定的是哪種adapter?我假設是最簡單的arrayAdapter,其實原理都一樣。
綁定adapter的數據大多數是數組。
數組的排序總會把?我記得是sort。
排序好再將數據綁定到adapter,然後adapter綁定到listview
9. android 中listview 的用法
1.在xml裡面定義一個ListView,這個xml是一個activity的layout文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ListView android:layout_width="wrap_content" //定義一個listView
android:layout_height="wrap_content"
android:id="@+id/ListView01"
/>
</LinearLayout>
2.定義ListView每個條目的Layout,比如命名為listview_item.xml,用RelativeLayout實現:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/RelativeLayout01"
android:layout_width="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:paddingBottom="4dip"
android:paddingLeft="12dip"
android:paddingRight="12dip">
<ImageView
android:paddingTop="12dip"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ItemImage"
/>
<TextView
android:text="TextView01"
android:layout_height="wrap_content"
android:textSize="20dip"
android:layout_width="fill_parent"
android:id="@+id/ItemTitle"
/>
<TextView
android:text="TextView02"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_below="@+id/ItemTitle"
android:id="@+id/ItemText"
/>
</RelativeLayout>
3.在Activity裡面調用和加入Listener,具體見注釋:
package com.ray.test;
import java.util.ArrayList;
import java.util.HashMap;
import android.app.Activity;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.MenuItem;
import android.view.View;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.View.OnCreateContextMenuListener;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.AdapterView.OnItemClickListener;
public class TestListView extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//綁定Layout裡面的ListView
ListView list = (ListView) findViewById(R.id.ListView01);
//生成動態數組,加入數據
ArrayList<HashMap<String, Object>> listItem = new ArrayList<HashMap<String, Object>>();
for(int i=0;i<10;i++)
{
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("ItemImage", R.drawable.checked);//圖像資源的ID
map.put("ItemTitle", "Level "+i);
map.put("ItemText", "Finished in 1 Min 54 Secs, 70 Moves! ");
listItem.add(map);
}
//生成適配器的Item和動態數組對應的元素,這里用SimpleAdapter作為ListView的數據源
//如果條目布局比較復雜,可以繼承BaseAdapter來定義自己的數據源。
SimpleAdapter listItemAdapter = new SimpleAdapter(this,listItem,//數據源
R.layout.list_items,//ListItem的XML實現
//動態數組與ImageItem對應的子項
new String[] {"ItemImage","ItemTitle", "ItemText"},
//ImageItem的XML文件裡面的一個ImageView,兩個TextView ID
new int[] {R.id.ItemImage,R.id.ItemTitle,R.id.ItemText}
);
//添加並且顯示
list.setAdapter(listItemAdapter);
//添加點擊
list.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
setTitle("點擊第"+arg2+"個項目");
}
});
//添加長按點擊
list.(new OnCreateContextMenuListener() {
@Override
public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo) {
menu.setHeaderTitle("長按菜單-ContextMenu");
menu.add(0, 0, 0, "彈出長按菜單0");
menu.add(0, 1, 0, "彈出長按菜單1");
}
});
}
//長按菜單響應函數
@Override
public boolean onContextItemSelected(MenuItem item) {
setTitle("點擊了長按菜單裡面的第"+item.getItemId()+"個項目");
return super.onContextItemSelected(item);
}
}