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


رتبه موضوع:
  • 0 رای - 0 میانگین
  • 1
  • 2
  • 3
  • 4
  • 5
قرار دادن 100 تصویر در برنامه اندروید و برای هر یک ، یک صفحه جداگانه

قرار دادن 100 تصویر در برنامه اندروید و برای هر یک ، یک صفحه جداگانه

#1
سلام 

من میخواستم درون برنامه ام 100 تصویر بزارم که هر تصویر هم داخل صفحه ی خاصی نشون داده بشه . راهی وجود داره که نخوام 100 تا xml و java ایجاد کنم؟

خیلی سریع نیاز دارم . تشکر .
پاسخ

قرار دادن 100 تصویر در برنامه اندروید و برای هر یک ، یک صفحه جداگانه

#2
تمام عکس هارو داخل یک اکتیوتی قرار بدید پشت سره هم و هم اندازه ، یک باتن درگ کنید ، با استفاده از دستور تایمر بهش بگین که بعد از لمس هر بار باتن چه عکسی نمایش داده بشه. با دستور Hide .
پاسخ
 سپاس شده توسط admin

قرار دادن 100 تصویر در برنامه اندروید و برای هر یک ، یک صفحه جداگانه

#3
خب میخوام تصاویر بتونن ذخیره هم بشن .
پاسخ

قرار دادن 100 تصویر در برنامه اندروید و برای هر یک ، یک صفحه جداگانه

#4
به نظر من یک لیست ویو با قابلیت کیک بر آن بساز و داده هات را در قالب یک آرایه ‌خیره کن. این طور دوتا اکتیویتی می سازی و نهایتا سه تا لی اوت
و کلید 843

کد پی‌اچ‌پی:
import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

public class 
MainActivity  extends ListActivity {
       
        public 
ListView lv;
        public 
String number_of_keys;
        public 
String my_items = {"key_1",
                                      
"key_2",
                                      
"key_3",
                                      
"key_4",
                                      
"key_5",
                                      
"key_6",
                                      
"key_7",
                                      
"key_8",
                                      
"key_9",
                                      
"key_10",
                                      
"key_11",
                                      
"key_12",
                                      
"key_13",
                                      
"key_14",
                                      
"key_15",
                                      
"key_16",
                                      
"key_17",
                                      
"key_18",
                                      
"key_19",
                                      
"key_20"
                                             
};

        @
Override
        
protected void onCreate(Bundle savedInstanceState) {
                
super.onCreate(savedInstanceState);
                
setContentView(R.layout.activity_main);
               
                
setListAdapter(new MyAdapter(this,
                                       
android.R.layout.simple_list_item_1,
                                       
R.id.textView1,
                                       
my_items));     
               
                
lv getListView();
                
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            @
Override
            
public void onItemClick(AdapterView<?> parent, final View view,
                int position, long id) {                       
                        Intent i = new Intent(getApplicationContext(), SecondActivity.class);
                        number_of_keys = String.valueOf(position+1);
                        i.putExtra("key_number", number_of_keys);
                        startActivity(i);      
            }

        });
        }

       
        private class MyAdapter extends ArrayAdapter<String>{

                public MyAdapter(Context context, int resource, int textViewResourceId,
                                String strings) {
                        super(context, resource, textViewResourceId, strings);
                        // TODO Auto-generated constructor stub
                }
               
                @Override
                public View getView(int position, View convertView, ViewGroup parent) {
                        LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                        View row = inflater.inflate(R.layout.list_item, parent, false);
                       
                        String stringName = "string_key_" + String.valueOf(position+1);
                        int string_res_ID = getResources().getIdentifier(stringName,"string",getPackageName());
                        String my_string = getResources().getString(string_res_ID);
                        TextView tv = (TextView) row.findViewById(R.id.textView1);
                        tv.setText(my_string);
                       
                        String imageName = "key_" + String.valueOf(position+1);
                        int image_res_ID = getResources().getIdentifier(imageName,"drawable",getPackageName());
                        ImageView iv = (ImageView) row.findViewById(R.id.imageView1);
                        iv.setImageResource(image_res_ID);
       
                        return row;
                }
               
               
        }
       


پاسخ
 سپاس شده توسط admin ، شماره مجازی امارات


پرش به انجمن:


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