omid9191 1 ارسال شده در ۲۳ مهر ۱۳۹۴ گزارش اشتراک گذاری ارسال شده در ۲۳ مهر ۱۳۹۴ سلام : من یه برنامه محتوایی دارم ولی وقتی محتویات دیتا بیسم زیاد میشه (در حال حاضر 2000 رکورد در چند جدول) در زمان نمایش در لیست ویو به سرعت نشون نمیده و یه تاخیر 2 ثانیه های داره . برای حل این مشکل چی پیشنهاد میدید؟ نقل قول لینک ارسال به اشتراک گذاری در سایت های دیگر
Seyed-Hossein-Akbari 92 ارسال شده در ۲۳ مهر ۱۳۹۴ گزارش اشتراک گذاری ارسال شده در ۲۳ مهر ۱۳۹۴ سلام شما اگر لیست ویو رو سفارشی درست کنید ! که از نوع Baseadapter باشه و ویوهولدر داشته باشید ! با کندی برخورد نخواهید کرد. نقل قول لینک ارسال به اشتراک گذاری در سایت های دیگر
omid9191 1 ارسال شده در ۲۴ مهر ۱۳۹۴ مالک گزارش اشتراک گذاری ارسال شده در ۲۴ مهر ۱۳۹۴ سلام شما اگر لیست ویو رو سفارشی درست کنید ! که از نوع Baseadapter باشه و ویوهولدر داشته باشید ! با کندی برخورد نخواهید کرد. کد های که استفاده کردم package com.AppLike.office_help_me; import android.app.ListActivity; import android.content.ClipData; import android.content.ClipboardManager; import android.content.Intent; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Color; import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; public class list_story_mail extends ListActivity { private database db; private String[] Name; private String[] Name_main; private String[] Tedad; private String[] Fav; private String sea; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.list_story_mail); android.app.ActionBar mActionBar = getActionBar(); mActionBar.setDisplayShowHomeEnabled(false); mActionBar.setDisplayShowTitleEnabled(false); LayoutInflater mInflater = LayoutInflater.from(this); View mCustomView = mInflater.inflate(R.layout.custom_actionbar, null); ImageButton imageButton = (ImageButton) mCustomView .findViewById(R.id.imageButton); imageButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent i = new Intent(list_story_mail.this,menu.class); startActivity(i); overridePendingTransition(R.anim.out, R.anim.in); } }); ImageButton btn_share = (ImageButton) mCustomView .findViewById(R.id.btn_share); btn_share.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { Intent s = new Intent(list_story_mail.this,MainActivity.class); startActivity(s); overridePendingTransition(R.anim.out, R.anim.in); } }); //فعال کردن اکشن بار سفارشی mActionBar.setCustomView(mCustomView); mActionBar.setDisplayShowCustomEnabled(true); db=new database(this); Bundle ex=getIntent().getExtras(); sea=ex.getString("sea"); refresh(); setListAdapter(new AAA()); TextView text_action = (TextView) mCustomView.findViewById(R.id.action_text); text_action.setText(sea); Typeface face = Typeface.createFromAsset(getAssets(), "font/koodak.ttf"); text_action.setTypeface(face); } class AAA extends ArrayAdapter{ public AAA(){ super(list_story_mail.this,R.layout.row_story_mail,Name); } @Override public View getView(final int position, View convertView, ViewGroup parent) { LayoutInflater in=getLayoutInflater(); View row=in.inflate(R.layout.row_story_mail, parent,false); final TextView name=(TextView) row.findViewById(R.id.row_story_name); final TextView tedad=(TextView) row.findViewById(R.id.row_story_tedad); final ImageView fav =(ImageView)row.findViewById(R.id.fav); final ImageView copy =(ImageView)row.findViewById(R.id.copy); Button btn_share = (Button)row.findViewById(R.id.share); TextView count_row = (TextView)row.findViewById(R.id.count_row); for(int i = 0 ; i<=position;i+=1){ count_row.setText(String.valueOf(position+1)); } Typeface face = Typeface.createFromAsset(getAssets(), "font/koodak.ttf"); count_row.setTypeface(face); btn_share.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent sharing = new Intent(android.content.Intent.ACTION_SEND); sharing.setType("text/plain"); sharing.putExtra(android.content.Intent.EXTRA_TEXT,name.getText().toString() +" : \n "+ tedad.getText().toString()+"\n \n ارسال شده از اپلیکیشن کمک یار اداره "); startActivity(Intent.createChooser(sharing, "اشتراک گذاری با")); } }); copy.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("",name.getText().toString() +" : \n "+ tedad.getText().toString()); clipboard.setPrimaryClip(clip); Toast toast_style = Toast.makeText(getApplicationContext(), "کپی شد", Toast.LENGTH_LONG); View vieew = toast_style.getView(); vieew.setBackgroundResource(R.drawable.toast_style); toast_style.setView(vieew); toast_style.show(); } }); if(Fav[position].equals("1")){ fav.setImageResource(R.drawable.ic_favorite_white_48dp); }else{ fav.setImageResource(R.drawable.ic_favorite_outline_white_48dp); } fav.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { db.open(); if(Fav[position].equals("1")){ db.fav_update("mail", sea, Name[position], "0"); fav.setImageResource(R.drawable.ic_favorite_outline_white_48dp); Fav[position]="0"; Toast toast_style =Toast.makeText(getApplicationContext(), "از لیست علاقه مندی های بخش نامه ها حذف شد", Toast.LENGTH_SHORT); View vieew = toast_style.getView(); vieew.setBackgroundResource(R.drawable.toast_style); toast_style.setView(vieew); toast_style.show(); }else{ db.fav_update("mail", sea, Name[position], "1"); fav.setImageResource(R.drawable.ic_favorite_white_48dp); Fav[position]="1"; Toast toast_style = Toast.makeText(getApplicationContext(), "به لیست علاقه مندی های بخش نامه ها اضافه شد", Toast.LENGTH_SHORT); View vieew = toast_style.getView(); vieew.setBackgroundResource(R.drawable.toast_style); toast_style.setView(vieew); toast_style.show(); } db.close(); } }); name.setTypeface(MainActivity.font); name.setTextSize(MainActivity.size); tedad.setTypeface(MainActivity.font); tedad.setTextSize(MainActivity.size); tedad.setLineSpacing(MainActivity.space,1); name.setText(Name[position]); tedad.setText(Name_main[position]); if(MainActivity.mode.equals("day")){ Resources res = getResources(); Drawable dr = res.getDrawable(R.drawable.day); row.setBackgroundDrawable(dr); name.setTextColor(Color.parseColor("#575757")); tedad.setTextColor(Color.parseColor("#575757")); }else{ Resources res = getResources(); Drawable dr = res.getDrawable(R.drawable.night); row.setBackgroundDrawable(dr); name.setTextColor(Color.WHITE); tedad.setTextColor(Color.WHITE); } return (row); } } private void refresh(){ db.open(); int s=db.S2_count("mail", sea); Name=new String[s]; Name_main=new String[s]; Tedad=new String[s]; Fav=new String[s]; for(int i=0;i Name[i]=db.Story2_display("mail", i, sea,1); Name_main[i]=db.Story2_display("mail", i, sea,2); // Tedad[i]=db.Story2_display("content", i, sea, 0); Fav[i]=db.Story2_display("mail", i, sea, 6); } db.close(); } public void onBackPressed() { super.onBackPressed(); finish(); overridePendingTransition(R.anim.out, R.anim.in); } } اگر اینجوری نباید باشه اگه میشه یه منبعی برای لودر معرفی کنید ممنون نقل قول لینک ارسال به اشتراک گذاری در سایت های دیگر
SASAN_AH 38 ارسال شده در ۲۴ مهر ۱۳۹۴ گزارش اشتراک گذاری ارسال شده در ۲۴ مهر ۱۳۹۴ سلام از کلاس ViewHolder استفاده کنید نقل قول لینک ارسال به اشتراک گذاری در سایت های دیگر
omid9191 1 ارسال شده در ۲۴ مهر ۱۳۹۴ مالک گزارش اشتراک گذاری ارسال شده در ۲۴ مهر ۱۳۹۴ سلام : ممنون از جوابتون اگه امکانش هست میشه این کلاس رو اینجا قرار بدید و بگید که چطور در کدی که در بالا گذاشتم استفاده کنم. نقل قول لینک ارسال به اشتراک گذاری در سایت های دیگر
omid9191 1 ارسال شده در ۲۵ مهر ۱۳۹۴ مالک گزارش اشتراک گذاری ارسال شده در ۲۵ مهر ۱۳۹۴ کسی نیست جواب بده که چه جوری میتونم viewholder رو در کدی که قرار دادم استفاده کنم واقعا نیاز دارم به استفاده از کلاس (viewholder) نقل قول لینک ارسال به اشتراک گذاری در سایت های دیگر
daniyal 2 ارسال شده در ۲۵ مهر ۱۳۹۴ گزارش اشتراک گذاری ارسال شده در ۲۵ مهر ۱۳۹۴ این لیست ویویی که خودم استفاده میکنم و تا حالا ندیدم کند بشه اکتیوتی اصلی public class ListViewActivity extends Activity { public ArrayAdapter adapter; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); adapter = new AdapterNote(G.notes); ListView lst = (ListView) findViewById(R.id.lst); lst.setAdapter(adapter); for (int i = 0; i < 20; i++) { StruckNote note = new StruckNote(); note.title = "title" + i; note.description = "description" + i; G.notes.add(note); } adapter.notifyDataSetChanged(); } } کلاس AdapterNote public class AdapterNote extends ArrayAdapter { public AdapterNote(ArrayList array) { super(G.context, R.layout.adapternote, array); } private static class ViewHolder { public ViewGroup Layout_Root; public TextView txtTitle; public TextView txtDesription; public ViewHolder(View view) { txtTitle = (TextView) view.findViewById(R.id.txtTitle); txtDesription = (TextView) view.findViewById(R.id.txtDesription); Layout_Root = (ViewGroup) view.findViewById(R.id.Layout_Root); } public void fill(ArrayAdapter adapter, final StruckNote item, int position) { txtTitle.setText(item.title); txtDesription.setText(item.description); Layout_Root.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent intent = new Intent(G.currentactivity, detail.class); G.currentactivity.startActivity(intent); } }); } } @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; StruckNote item = getItem(position); if (convertView == null) { convertView = G.in.inflate(R.layout.adapternote, parent, false); holder = new ViewHolder(convertView); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.fill(this, item, position); return convertView; } } کلاس G public class G extends Application { public static Context context; public static LayoutInflater in; public static Activity currentactivity; public static ArrayList notes = new ArrayList(); @Override public void onCreate() { super.onCreate(); context = getApplicationContext(); in = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); } } کلاسStruckNote public class StruckNote { public String title; public String description; } نقل قول لینک ارسال به اشتراک گذاری در سایت های دیگر
mr.smf8 8 ارسال شده در ۲۵ مهر ۱۳۹۴ گزارش اشتراک گذاری ارسال شده در ۲۵ مهر ۱۳۹۴ چرا توسعه دهنده های ایرانی دوست دارن 2 سال قبل از تکنولوژی زندگی کنند ! خب دوست عزیز شما راحت با RecyclerView میتونید مشکلتون رو حل کنید http://developer.android.com/training/material/lists-cards.html یه نمونه ساده ! اگه حل نشد بگید که یه کاری دیگه بکنم نقل قول لینک ارسال به اشتراک گذاری در سایت های دیگر
omid9191 1 ارسال شده در ۲۷ مهر ۱۳۹۴ مالک گزارش اشتراک گذاری ارسال شده در ۲۷ مهر ۱۳۹۴ ممنون از راهنمیتون : نیشه بگید چطور میتونم از RecyclerView در کدهام قرار بدم ؟ نیاز به لایبری خاصی داره و یا اینکه برای هر اکتیویته که داخلش لیست ویو هست باید از RecyclerView استفاده بشه ؟ اگر زحمتی نیست بگید چطور در کدهام قرار بدم (کد رو در بالا قرار دادم ) نقل قول لینک ارسال به اشتراک گذاری در سایت های دیگر
پست های پیشنهاد شده
به گفتگو بپیوندید
هم اکنون می توانید مطلب خود را ارسال نمایید و بعداً ثبت نام کنید. اگر حساب کاربری دارید، برای ارسال با حساب کاربری خود اکنون وارد شوید .