PDA

View Full Version : مشکل با گالری تصاویر



sahar_mrd69
شنبه 01 شهریور 1393, 22:48 عصر
سلام.یه گالری تصاویر توی پروژم استفاده کردم وقتی توی جنی موشن اجرا میکنم تمام تصاویرو به خوبی نشون میده اما نمیدونم چرا وقتی روی گوشی یا امولیتو 4 اجرا میکنم تصاویر رو نشون نمیده؟

smemamian
شنبه 01 شهریور 1393, 22:59 عصر
سلام
این تصاویر از کجا گرفته می شود ؟ از کتابخانه ی خاصی استفاده می کنید ؟ (چون ممکن است اون کتابخانه minsdk متفاوتی با minsdk
شما داشته باشد.) یا..

sahar_mrd69
شنبه 01 شهریور 1393, 23:09 عصر
این نمونه کدم توی mainactivityهست
public class MainActiviti extends Activity implements OnItemSelectedListener, TextWatcher {

Singleton m_Inst = Singleton.getInstance();
CarouselViewAdapter m_carouselAdapter = null;
final int m_nFirstItem = 1000;


@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

//no keyboard unless requested by user
getWindow().setSoftInputMode(WindowManager.LayoutP arams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

// compute screen size and scaling
Singleton.getInstance().InitGUIFrame(this);

int padding = m_Inst.Scale(10);
// create the interface : full screen container
RelativeLayout panel = new RelativeLayout(this);
panel.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
panel.setPadding(padding, padding, padding, padding);
panel.setBackgroundDrawable(new GradientDrawable(GradientDrawable.Orientation.TOP_ BOTTOM,
new int[]{ Color.WHITE, Color.GRAY }));
setContentView(panel);

// copy images from assets to sdcard
AppUtils.AssetFileCopy(this, "/mnt/sdcard/plasma1.png", "plasma1.png", false);
AppUtils.AssetFileCopy(this, "/mnt/sdcard/plasma2.png", "plasma2.png", false);
AppUtils.AssetFileCopy(this, "/mnt/sdcard/plasma3.png", "plasma3.png", false);
AppUtils.AssetFileCopy(this, "/mnt/sdcard/plasma4.png", "plasma4.png", false);
AppUtils.AssetFileCopy(this, "/mnt/sdcard/plasma5.png", "plasma5.png", false);
AppUtils.AssetFileCopy(this, "/mnt/sdcard/plasma6.png", "plasma6.png", false);
AppUtils.AssetFileCopy(this, "/mnt/sdcard/plasma7.png", "plasma7.png", false);
AppUtils.AssetFileCopy(this, "/mnt/sdcard/plasma8.png", "plasma8.png", false);
AppUtils.AssetFileCopy(this, "/mnt/sdcard/plasma9.png", "plasma9.png", false);
AppUtils.AssetFileCopy(this, "/mnt/sdcard/plasma10.png", "plasma10.png", false);
AppUtils.AssetFileCopy(this, "/mnt/sdcard/plasma11.png", "plasma11.png", false);
AppUtils.AssetFileCopy(this, "/mnt/sdcard/plasma12.png", "plasma12.png", false);
//Create carousel view documents
ArrayList<CarouselDataItem> Docus = new ArrayList<CarouselDataItem>();
for (int i = 0; i < 1000; i++) {
CarouselDataItem docu;
if (i % 12 == 0)
docu = new CarouselDataItem("/mnt/sdcard/plasma1.png", 0, "First Image ");
else if (i % 12 == 1)
docu = new CarouselDataItem("/mnt/sdcard/plasma2.png", 0, "Second Image ");
else if (i % 12 == 2)
docu = new CarouselDataItem("/mnt/sdcard/plasma3.png", 0, "Third Image ");
else if (i % 12 == 3)
docu = new CarouselDataItem("/mnt/sdcard/plasma4.png", 0, "four Image ");
else if (i % 12 == 4)
docu = new CarouselDataItem("/mnt/sdcard/plasma5.png", 0, "five Image ");
else if (i % 12 == 5)
docu = new CarouselDataItem("/mnt/sdcard/plasma6.png", 0, "six Image ");
else if (i % 12 == 6)
docu = new CarouselDataItem("/mnt/sdcard/plasma7.png", 0, "seven Image ");
else if (i % 12 == 7)
docu = new CarouselDataItem("/mnt/sdcard/plasma8.png", 0, "eight Image ");
else if (i % 12 == 8)
docu = new CarouselDataItem("/mnt/sdcard/plasma9.png", 0, "nine Image ");
else if (i % 12 == 9)
docu = new CarouselDataItem("/mnt/sdcard/plasma10.png", 0, "ten Image ");
else if (i % 12 == 10)
docu = new CarouselDataItem("/mnt/sdcard/plasma11.png", 0, "eleven Image ");
else
docu = new CarouselDataItem("/mnt/sdcard/plasma12.png", 0, "tuen Image ");
Docus.add(docu);
}

// add the serach filter
EditText etSearch = new EditText(this);
etSearch.setHint("Search your documents");
etSearch.setSingleLine();
etSearch.setTextColor(Color.BLACK);
etSearch.setCompoundDrawablesWithIntrinsicBounds(R .drawable.ic_menu_search, 0, 0, 0);
AppUtils.AddView(panel, etSearch, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
new int[][]{ new int[]{ RelativeLayout.CENTER_HORIZONTAL }, new int[]{ RelativeLayout.ALIGN_PARENT_TOP } }, -1, -1);
etSearch.addTextChangedListener((TextWatcher) this);

// add logo
TextView tv = new TextView(this);
tv.setTextColor(Color.BLACK);
tv.setText("narjes.mansuri@gmail.com");
AppUtils.AddView(panel, tv, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
new int[][]{ new int[]{ RelativeLayout.CENTER_HORIZONTAL }, new int[]{ RelativeLayout.ALIGN_PARENT_BOTTOM } }, -1, -1);

// create the carousel
CarouselView coverFlow = new CarouselView(this);

// create adapter and specify device independent items size (scaling)
// for more details see: http://www.pocketmagic.net/2013/04/how-to-scale-an-android-ui-on-multiple-screens/
m_carouselAdapter = new CarouselViewAdapter(this, Docus, m_Inst.Scale(400), m_Inst.Scale(300));
coverFlow.setAdapter(m_carouselAdapter);
coverFlow.setSpacing( -1 * m_Inst.Scale(150));
coverFlow.setSelection(Integer.MAX_VALUE / 2, true);
coverFlow.setAnimationDuration(1000);
coverFlow.setOnItemSelectedListener((OnItemSelecte dListener) this);

AppUtils.AddView(panel, coverFlow, LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT,
new int[][]{ new int[]{ RelativeLayout.CENTER_IN_PARENT } },
-1, -1);
}

razavi66
شنبه 01 شهریور 1393, 23:17 عصر
خواهش میکنم به سوال منم جواب بدید

لینک :

http://barnamenevis.org/showthread.php?466191-%DA%A9%D9%85%DA%A9-%D9%85%D8%B4%DA%A9%D9%84-%D8%AF%D8%B1-%D9%81%D8%A7%DB%8C%D9%84-R-java-%D9%81%D9%88%D8%B1%DB%8C-%D9%85%D9%87%D9%85

smemamian
یک شنبه 02 شهریور 1393, 00:18 صبح
کدهاتون رو داخل تگ جاوا بذارید!!!!

sahar_mrd69
یک شنبه 02 شهریور 1393, 00:53 صبح
ArrayList<CarouselDataItem> Docus = new ArrayList<CarouselDataItem>();
for (int i = 0; i < 1000; i++) {
CarouselDataItem docu;
if (i % 12 == 0)
docu = new CarouselDataItem("/mnt/sdcard/plasma1.png", 0, "First Image ");
else if (i % 12 == 1)
docu = new CarouselDataItem("/mnt/sdcard/plasma2.png", 0, "Second Image ");
else if (i % 12 == 2)
docu = new CarouselDataItem("/mnt/sdcard/plasma3.png", 0, "Third Image ");
else if (i % 12 == 3)
docu = new CarouselDataItem("/mnt/sdcard/plasma4.png", 0, "four Image ");
else if (i % 12 == 4)
docu = new CarouselDataItem("/mnt/sdcard/plasma5.png", 0, "five Image ");
else if (i % 12 == 5)
docu = new CarouselDataItem("/mnt/sdcard/plasma6.png", 0, "six Image ");
else if (i % 12 == 6)
docu = new CarouselDataItem("/mnt/sdcard/plasma7.png", 0, "seven Image ");
else if (i % 12 == 7)
docu = new CarouselDataItem("/mnt/sdcard/plasma8.png", 0, "eight Image ");
else if (i % 12 == 8)
docu = new CarouselDataItem("/mnt/sdcard/plasma9.png", 0, "nine Image ");
else if (i % 12 == 9)
docu = new CarouselDataItem("/mnt/sdcard/plasma10.png", 0, "ten Image ");
else if (i % 12 == 10)
docu = new CarouselDataItem("/mnt/sdcard/plasma11.png", 0, "eleven Image ");
else
docu = new CarouselDataItem("/mnt/sdcard/plasma12.png", 0, "tuen Image ");
Docus.add(docu);
}


EditText etSearch = new EditText(this);
etSearch.setHint("Search your documents");
etSearch.setSingleLine();
etSearch.setTextColor(Color.BLACK);
etSearch.setCompoundDrawablesWithIntrinsicBounds(R .drawable.ic_menu_search, 0, 0, 0);
AppUtils.AddView(panel, etSearch, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
new int[][]{ new int[]{ RelativeLayout.CENTER_HORIZONTAL }, new int[]{ RelativeLayout.ALIGN_PARENT_TOP } }, -1, -1);
etSearch.addTextChangedListener((TextWatcher) this);

TextView tv = new TextView(this);
tv.setTextColor(Color.BLACK);
tv.setText("narjes.mansuri@gmail.com");
AppUtils.AddView(panel, tv, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
new int[][]{ new int[]{ RelativeLayout.CENTER_HORIZONTAL }, new int[]{ RelativeLayout.ALIGN_PARENT_BOTTOM } }, -1, -1);


CarouselView coverFlow = new CarouselView(this);


m_carouselAdapter = new CarouselViewAdapter(this, Docus, m_Inst.Scale(400), m_Inst.Scale(300));
coverFlow.setAdapter(m_carouselAdapter);
coverFlow.setSpacing( -1 * m_Inst.Scale(150));
coverFlow.setSelection(Integer.MAX_VALUE / 2, true);
coverFlow.setAnimationDuration(1000);
coverFlow.setOnItemSelectedListener((OnItemSelecte dListener) this);

AppUtils.AddView(panel, coverFlow, LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT,
new int[][]{ new int[]{ RelativeLayout.CENTER_IN_PARENT } },
-1, -1);
}

smemamian
یک شنبه 02 شهریور 1393, 17:08 عصر
اگر هیچ پیغام خطایی دریافت نمی کنید، مشکل از scale کردن هست.
فکر کنم شما دارید از یک کلاس/تابع/کتابخانه جهت scale تصاویر استفاده می کنید.
نرم افزار رو روی گوشی های دیگر تست کنید و نتیجه رو ببینید. اگر از یک کلاس/تابع/کتابخانه
استفاده می کنید بدون اون کلاس/تابع/کتابخانه گالری رو تست کنید.

در ضمن شما باید در خط 4 تا 26 بالا، از switch استفاده کنید نه if و else های متعدد.

scale تصاویر در گوشی های اندروید، زیاد عاقلانه نیست. چون در scale کردن توابعی همچون recycle
فراخوانی میشه که این چنین توابع روی گوشی های مختلف، بازخورد متفاوتی دارند.