導航:首頁 > 操作系統 > androidgalleryview

androidgalleryview

發布時間:2022-07-11 09:59:13

1. android Gallery畫廊出錯

看代碼應該是沒有問題的,但是你的logcat我實在是看不清楚,首先確保你的TextView 和 Gallery確實包含在你的R.layout.main 的XML文件裡面,其次你的ImageAdapter 要寫在另一個class文件裡面,因為只能有一個public 類,另外你的代碼我在4.0 模擬器測試了一下,沒有任何問題,有問題可以再問,謝謝採納。

2. 如何自定義galleryview里圖片可重疊 android

setSpacing(-180);


這個就是Gallery實現的效果

3. android 在Gallery下面加入導航條視圖,當拖動Gallery時,導航條根據當前圖片在Gallery中的位置而顯示進度

Gallery是一個類似於ListView的視圖可以實現左右緩慢拖動屏幕切換圖片的功能

package com.test;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.text.Layout;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.LinearLayout.LayoutParams;

public class SpinnerActivity extends Activity {
private Gallery gallery;
private List<Bitmap> list = new ArrayList<Bitmap>();;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
gallery = (Gallery) findViewById(R.id.images);
init();
gallery.setAdapter(new MyAdapter());

}

private void init() {
// 通過圖片工廠得到圖片對象,並加入到集合中
list.add(BitmapFactory.decodeResource(getResources(), R.drawable.icon));
list.add(BitmapFactory.decodeResource(getResources(), R.drawable.icon));
list.add(BitmapFactory.decodeResource(getResources(), R.drawable.icon));
list.add(BitmapFactory.decodeResource(getResources(), R.drawable.icon));
list.add(BitmapFactory.decodeResource(getResources(), R.drawable.icon));

}

class MyAdapter extends BaseAdapter

4. android Gallery為啥被廢棄

給廢棄了是因為有更好的控制項可以取代了,我所知道的有HorizontalScrollView,ViewPager,你可以查看Android的API文檔,裡面有更詳細的理由。

5. android gallery中顯示圖片加數字問題

很簡單的實現,使用framerlayout布局,後創建的控制項TextView(用於顯示Gallery的編號)會浮在先創建的控制項ImageView上面,即Gallery上面,你只需要這只Gallery的選中事件,將每張圖片對應的position通過TextView.setText()的方式填入就行.

6. 如何獲取android gallery 當前顯示的圖片的position

通過gallery對象的方法setOnItemSelectedListener獲取
1、獲得gallery對象,並設置gallery的適配器,最好自定義適配器,即繼承BaseAdapter
2、設置gallery的單個item的點擊事件setOnItemSelectedListener,

gallery.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View v,int position, long id) {
}

@Override
public void onNothingSelected(AdapterView<?> arg0) {
//這里不做響應
}
});
上面的 onItemSelected 中 ,參數position就是當前顯示的圖片position

7. 怎樣向android的Gallery里動態添加圖片

Gallery使用大致方法為
1
定義綁定
mGallery
=
(Gallery)findView...
2
定義適配器
MyAdapter
mAdapter
=
new
MyAdapter(.....,list);
注意list
3
為Gallery設置適配器
mGallery.setAdapter(mAdapter);
然後回到問題如何動態添加圖片,
list是你的數據源,新加的圖片資源應該加到list中,然後刷新Adapter就行了,比如點擊某按鈕添加某張圖片
button.setOnClickListener(new
OnClickListener()
{
@Override
public
void
onClick(View
v)
{
1.添加圖片,本地或者網路圖片根據你的需要
list.add("picture");
2.刷新適配器
mAdapter.notifyDataSetChanged();
}
});

閱讀全文

與androidgalleryview相關的資料

熱點內容
為什麼小度APP一直連不上網路 瀏覽:163
pdf模板java 瀏覽:40
現代瑞納的壓縮比 瀏覽:128
網吧里的ftp伺服器有什麼用 瀏覽:872
程序員年終總結工作體會 瀏覽:153
pdf可以直接列印 瀏覽:661
android刷wp8 瀏覽:912
歷史地圖集pdf 瀏覽:925
快手app極速版怎麼掃碼 瀏覽:805
qq程序員玩法 瀏覽:95
1是什麼門電路app 瀏覽:867
博之輪運動手錶用什麼app 瀏覽:646
asp視頻聊天源碼 瀏覽:85
網路游戲編程pdf 瀏覽:534
360壓縮出錯 瀏覽:848
源碼編輯器沒聲音 瀏覽:915
兒童源碼編程網址 瀏覽:828
有個app叫尺度空間怎麼樣 瀏覽:674
微博登陸java 瀏覽:683
一枚程序員 瀏覽:744