Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to refresh the ListView
    text
    copied!<p>After i click "more" button, it suppose will extend the listview from 10 to 20.</p> <p>However after clicked, the list view did not extend and remain original size.</p> <p>It only can keep the position of scroll bar. This is half of what i need.</p> <pre><code>newsid = new int[webservice.news.size()]; title = new String[webservice.news.size()]; date = new String[webservice.news.size()]; imagepath = new String[webservice.news.size()]; for (int i = 0; i &lt; webservice.news.size(); i++) { newsid[i] = webservice.news.get(i).getID(); title[i] = webservice.news.get(i).getNtitle(); date[i] = webservice.news.get(i).getNArticalD(); imagepath[i] = webservice.news.get(i).getImagePath(); } adapter = new CustomAdapter_ParticularCategoryAllNews(this, title, date, imagepath); lv.addFooterView(footermore); if (constant.isOnline()) { lv.addFooterView(constant.AdMob()); } TextView titletext = (TextView) findViewById(R.id.text_pagetitle); titletext.setText(pagetitletext.toString()); lv.setAdapter(adapter); </code></pre> <p>This is call when launch activity.</p> <pre><code>btnmore.setOnClickListener(new OnClickListener() { public void onClick(View arg0) { for (int i = 0; i &lt; webservice.news.size(); i++) { newsid[i] = webservice.news.get(i).getID(); title[i] = webservice.news.get(i).getNtitle(); date[i] = webservice.news.get(i).getNArticalD(); imagepath[i] = webservice.news.get(i).getImagePath(); } adapter.setTitle(title); adapter.setDate(date); adapter.setImagepath(imagepath); position = lv.getFirstVisiblePosition(); lv.smoothScrollToPosition(position); adapter.notifyDataSetChanged(); </code></pre> <p>This is what i call after i click "more button". However the list did not extend from 10 to 20 items.</p> <pre><code>public class CustomAdapter_ParticularCategoryAllNews extends BaseAdapter { private Activity activity; private String[] title, date, imagepath; private static LayoutInflater inflater = null; private ImageLoader_Loader imageLoader; private WindowManager wm = null; private Display display; private Config_ConstantVariable constant; public CustomAdapter_ParticularCategoryAllNews(Activity a, String[] title, String[] date, String[] imagepath) { activity = a; this.title = title; this.date = date; this.imagepath = imagepath; inflater = (LayoutInflater) activity .getSystemService(Context.LAYOUT_INFLATER_SERVICE); wm = (WindowManager) activity.getSystemService(Context.WINDOW_SERVICE); imageLoader = new ImageLoader_Loader(activity.getApplicationContext()); constant = new Config_ConstantVariable(activity); } public int getCount() { return title.length; } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public void setTitle(String[] title) { this.title = title; } public void setDate(String[] date) { this.date = date; } public void setImagepath(String[] imagepath) { this.imagepath = imagepath; } public View getView(int position, View convertView, ViewGroup parent) { View vi = convertView; if (convertView == null) vi = inflater.inflate(R.layout.main_particularcategoryallnewslist, parent, false); LinearLayout linear = (LinearLayout) vi.findViewById(R.id.layout_image); ImageView imageview = (ImageView) vi .findViewById(R.id.image_categoryallnewstitle); TextView titletext = (TextView) vi .findViewById(R.id.text_categoryallnewstitle); TextView datetext = (TextView) vi.findViewById(R.id.text_newsdate); if (!imagepath[position].toString().equals("no picture")) { imageview.setVisibility(View.VISIBLE); linear.setVisibility(View.VISIBLE); imageLoader.DisplayImage(imagepath[position], imageview); } else { imageview.setVisibility(View.GONE); imageview.setImageDrawable(null); linear.setVisibility(View.GONE); display = wm.getDefaultDisplay(); int screenWidth = display.getWidth(); titletext.setWidth(screenWidth); } if (constant.getscreenresolution() &gt;= 800 &amp;&amp; constant.ScreenOrientation() == 1) { titletext.setTextSize(TypedValue.COMPLEX_UNIT_PX, 30); datetext.setTextSize(TypedValue.COMPLEX_UNIT_PX, 20); } titletext.setText(title[position].toString()); datetext.setText(date[position].toString()); return vi; } </code></pre> <p>}</p> <p>This is the CustomAdapter class.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload