انجمن سایت کلیدستان


رتبه موضوع:
  • 0 رای - 0 میانگین
  • 1
  • 2
  • 3
  • 4
  • 5
بزرگنمایی عکس در گالری (در برنامه نویسی اندروید)

بزرگنمایی عکس در گالری (در برنامه نویسی اندروید)

#1
سوال دوستان عزیز.... من یه گالری دارم  نمیتونم چجور باید عکسا توی گالری بزرگ بشن .....اینم کد اکتیویتی گالری من:

کد پی‌اچ‌پی:
package com.example.shadfar;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.AdapterView.OnItemSelectedListener;



public class 
Gall extends Activity {

    
TextView mySelection;
    
Gallery myGallery;
    
ImageView img;
    
    @
Override
    
public void onCreate(Bundle savedInstanceState) {
        
super.onCreate(savedInstanceState);
        
setContentView(R.layout.gall);
        
        final 
int myImageIds = { 
                
R.drawable.b1
                
R.drawable.b2
                
R.drawable.b3
                
R.drawable.b4,
                
R.drawable.b5,
                
R.drawable.b6,
                
R.drawable.b7,
                
R.drawable.b8,
                
R.drawable.b9,
                
R.drawable.b10,
                
R.drawable.b11,
                
R.drawable.b12,
                
R.drawable.b13,
                
R.drawable.b14,
                
R.drawable.b15,
                
R.drawable.b16,
                
R.drawable.b17,
                
R.drawable.b18,
                
R.drawable.b19,
                
R.drawable.b20,
                
R.drawable.b21,
                
R.drawable.b22,
                
R.drawable.b23,
                
R.drawable.b24,
                
R.drawable.b25,
                
R.drawable.b26,
                
R.drawable.b27,
                
R.drawable.b28,
                
R.drawable.b29,
                
R.drawable.b30,
                
R.drawable.b31,
                
            
        };
        
        
mySelection = (TextViewfindViewById(R.id.textView2);        
        
myGallery = (GalleryfindViewById(R.id.myGallery);
        
img = (ImageViewfindViewById(R.id.imageView1);
 
        
myGallery.setAdapter(new ImageAdapter(this));
        
        
myGallery.setOnItemSelectedListener(new OnItemSelectedListener() {
 
            public 
void onItemSelected(AdapterView<?> parent, View v,
                    int position, long id) {
                
                mySelection.setText(" selected option: " + position );
                
                img.setImageResource(myImageIds[position]);
            }
 
            public void onNothingSelected(AdapterView<?parent) {
                
                
mySelection.setText("Nothing selected");
            }
        });
    }
 
    public class 
ImageAdapter extends BaseAdapter {
 
        private 
Context myContext;
        
        private 
int myImageIds = { 
                
R.drawable.b1
                
R.drawable.b2
                
R.drawable.b3
                
R.drawable.b4,
                
R.drawable.b5,
                
R.drawable.b6,
                
R.drawable.b7,
                
R.drawable.b8,
                
R.drawable.b9,
                
R.drawable.b10,
                
R.drawable.b11,
                
R.drawable.b12,
                
R.drawable.b13,
                
R.drawable.b14,
                
R.drawable.b15,
                
R.drawable.b16,
                
R.drawable.b17,
                
R.drawable.b18,
                
R.drawable.b19,
                
R.drawable.b20,
                
R.drawable.b21,
                
R.drawable.b22,
                
R.drawable.b23,
                
R.drawable.b24,
                
R.drawable.b25,
                
R.drawable.b26,
                
R.drawable.b27,
                
R.drawable.b28,
                
R.drawable.b29,
                
R.drawable.b30,
                
R.drawable.b31,
            
                
        };

        public 
ImageAdapter(Context c) {
            
this.myContext c;
        }
 
        public 
int getCount() {
            return 
this.myImageIds.length;
        }
 
        public 
Object getItem(int position) {
            return 
position;
        }
 
        public 
long getItemId(int position) {
            return 
position;
        }
        
// Returns a new ImageView to be displayed,
        
public View getView(int positionView convertView,ViewGroup parent
        
        {
 
            
ImageView iv = new ImageView(this.myContext);
            
iv.setImageResource(this.myImageIds[position]);
 
            
iv.setScaleType(ImageView.ScaleType.FIT_END);
            
            
// Set the Width & Height of the individual images
            
iv.setLayoutParams(new Gallery.LayoutParams(9570));
 
            return 
iv;
        }
    }


هر کی بلد کمک کنه خیلی وقته برنامه رو گذاشتم بازار    ولی تایید نشده[عکس: undecided.gif][عکس: undecided.gif]
کار نشد نداره.... توکل کن....
پاسخ


پیام‌های این موضوع
بزرگنمایی عکس در گالری (در برنامه نویسی اندروید) - توسط hamidcuber72 - ۱۳۹۴/۰۶/۰۸, ۱۱:۵۶ ق.ظ
RE: بزرگنمایی عکس در گالری - توسط rayej.ir - ۱۳۹۴/۰۶/۰۹, ۱۰:۱۸ ق.ظ
RE: بزرگنمایی عکس در گالری - توسط hamidcuber72 - ۱۳۹۴/۰۶/۱۳, ۰۷:۱۲ ب.ظ
RE: بزرگنمایی عکس در گالری - توسط hamidcuber72 - ۱۳۹۴/۰۶/۱۶, ۱۰:۱۰ ق.ظ

پرش به انجمن:


کاربران در حال بازدید این موضوع: 1 مهمان