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


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

ست کردن تصویر دوربین بر روی گرید ویو (در برنامه نویسی اندروید)

#4
[font]ممنونم از لطف شما من سعی کردم ، اما متاسفانه نتونستم مشکلم رو بر طرف کنم ، کد ها ی برنامه رو میزارم ممنون میشم راهنمایی کنید ،چیکار باید بکنم 

کلاس adapternote  که گرید عناصر گرید ویو معرفی میشوند و ....
[/font]
[font][i]​[/i][/font]
کد پی‌اچ‌پی:
public class AdapterNote extends ArrayAdapter<StructNote> {
    



    public 
AdapterNote(ArrayList<StructNote> array) {
        
super(G.contextR.layout.adapter_note, array);

    }


    public static class 
ViewHolder {

        public 
ViewGroup layoutimg;

        public 
ViewGroup layoutdescription;

        public 
TextView  description;

       public 
ImageView imgcontact;
       
       public static 
Context               context;

        protected 
int    TAKE_PICTURE;

           public  
ImageView imgcon;
    

        public 
ViewHolder(View view) {


            
//layoutimg = (ViewGroup)view.findViewById(R.id.layoutimg);
            
            
imgcon = ( ImageView)view.findViewById(R.id.imgcon);
        }
        
            public 
void fill(final ArrayAdapter<StructNoteadapter, final StructNote item, final int position) {

                
imgcon.setOnClickListener(new OnClickListener() {

            
            @
Override
            
public void onClick(View view) {
                  
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                    
G.currentActivity.startActivityForResult(intentTAKE_PICTURE);
                        
            }                            

        });        
        
        }      
             
    
    protected 
void onActivityResult(int requestCodeint resultCodeIntent data) {

            
                if (
requestCode == TAKE_PICTURE) {

                    {
                      
                    
//    Uri selectedImage = data.getData();
                    //    String[] filePathColumn = { MediaStore.Images.Media.DATA };
             //
               //         getContentResolver();
                    //    Cursor cursor = Media.query(null, selectedImage,
                              //  filePathColumn, null, null, null);
                       // cursor.moveToFirst();
             
                        //int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
                       // String picturePath = cursor.getString(columnIndex);
                        //cursor.close();
                         
                        //ImageView imageView = (ImageView) findViewById(R.id.imgView);
                       // imageView.setImageBitmap(BitmapFactory.decodeFile(picturePath))
                     // ImageView imgcon = (ImageView) findViewById(R.id.imgcon);
                 

                   //    Bitmap photo = (Bitmap) data.getExtras().get("data");
                       
                    //  imgcon.setImageBitmap(photo);
                     //  Log.i("LOG", "return from camera");

                    
}
                }

                
layoutdescription.setOnClickListener(new OnClickListener() {

                    @
Override
                    
public void onClick(View view) {

                        
Intent intent = new Intent(G.currentActivityActivtySmsBody.class);

                       
G.currentActivity.startActivity(intent);

                    }
                });

            }
        }
      

    @
Override
    
public View getView(int positionView convertViewViewGroup parent) {      
                        
        
ViewHolder holder;
        
StructNote item getItem(position);     
                       
        if (
convertView == null) {                      
            
            
convertView G.inflater.inflate(R.layout.adapter_noteparentfalse);
            
            
holder = new ViewHolder(convertView); 
            
convertView.setTag(holder);
        } else {
            
holder = (ViewHolderconvertView.getTag();
        }

        
holder.fill(thisitemposition);
        return 
convertView;
    }



    } 
کلاس G
کد پی‌اچ‌پی:
public class extends Application {

    public class 
context {

    }

    public static 
LayoutInflater        inflater;
    public static 
SharedPreferences     preferences;
    public static 
String                defaultBackground;
    public static 
String                animation;
    public static 
Activity              currentActivity;
    public static 
ArrayList<StructNotenotes   = new ArrayList<StructNote>();
    public static 
String                DIR_APP Environment.getExternalStorageDirectory().getAbsolutePath() + "/cameraCapture";
    public static 
Context               context;
    public static 
int                   Itemimge;
    


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

        
context getApplicationContext();

        
inflater = (LayoutInflatergetSystemService(Context.LAYOUT_INFLATER_SERVICE);

        
preferences PreferenceManager.getDefaultSharedPreferences(context);
        
defaultBackground preferences.getString("default_background""theme00");
        
animation preferences.getString("default_animation""anim00");
        new 
File(DIR_APP).mkdirs();
    }


activitymain  که گرید ویو توش قرار داره و notifydatasetchange روش انجام می گیره 
کد پی‌اچ‌پی:
public class IconImage extends Activity {
    
  
    public 
ArrayAdapter adapter;


    @
Override
    
protected void onResume() {
        
G.currentActivity this;

        
super.onResume();
      if (
adapter != null) {
         
adapter.notifyDataSetChanged();
     }
  }


    @
Override
    
protected void onCreate(Bundle savedInstanceState) {
        
super.onCreate(savedInstanceState);
        
setContentView(R.layout.icon_image);
        
        final 
GridView gridv = (GridViewfindViewById(R.id.gridv);
        
        
adapter = new AdapterNote(G.notes);
        
gridv.setAdapter(adapter);

        for (
int i 0102i++) {

            
StructNote note = new StructNote();
            
            
note.description "Textviw " i;
            
note.ImageView "image_res_ID" != null ;

            
G.notes.add(note);
        }

        
adapter.notifyDataSetChanged();

    }


    } 
کلاس structnote  که گریدویو ازش تغذیه میشه و عناصرشو در این کلاس تعریف کردم ​
کد پی‌اچ‌پی:
public class StructNote {

    public 
String  description;

    public 
Bitmap  imgcontact;

    public 
Bitmap imgcon;

    public 
int     position;
    public 
Bitmap  lstContent;

    public 
boolean ImageView;
    public 
int textView;
    public 
int  ResourceId;


البته به نظر خودم imgcon رو به صورت یک لایه تعریف کنم بهتره میشه و به عبارتی وقتی رو لایه کلیک شد باید دوربین باز بشه و تصویر خروجی روی ایمیج ویوی مورد نظر که کلیک شده ست بشه ، ؟؟؟؟

ممنون میشم راهنمایی کنید ، که چطوری خروجی دوربین رو که به صورت بیت مپ هستش روی همون آیتم گرید ویو که ایمج ویو قرار دادم ست بشه ،؟؟؟  

با سپاس فراوان از دوستان عزیز  
پاسخ
 سپاس شده توسط شماره مجازی امارات


پیام‌های این موضوع
RE: ست کردن تصویر دوربین بر روی گرید ویو - توسط admin - ۱۳۹۳/۱۱/۲۰, ۰۹:۲۶ ب.ظ
RE: ست کردن تصویر دوربین بر روی گرید ویو - توسط masterapp - ۱۳۹۳/۱۱/۲۶, ۰۱:۰۹ ق.ظ

پرش به انجمن:


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