Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing viewpager in my application
    primarykey
    data
    text
    <p>I want to use viewpager in my application.I'm tried to do this everyday in one month but i can't achieve the solution.I want to create pages with same listview concept but different datas.Here is my code:</p> <pre><code>public final class TestFragment extends ListFragment { private static final String KEY_CONTENT = "TestFragment:Content"; ArrayList &lt;HashMap&lt;String, Object&gt;&gt; imageliste = new ArrayList&lt;HashMap&lt;String, Object&gt;&gt;(); public class MyCustomAdapter extends ArrayAdapter&lt;HashMap&lt;String, Object&gt;&gt; { //Bitmap bm; public MyCustomAdapter(Context context, int textViewResourceId, ArrayList&lt;HashMap&lt;String,Object&gt;&gt; imageliste) { super(context, textViewResourceId,imageliste); // TODO Auto-generated constructor stub } @Override public View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub //return super.getView(position, convertView, parent); View row = convertView; if(row==null){ LayoutInflater inflater=LayoutInflater.from(getActivity()); row=inflater.inflate(R.layout.list, parent, false); } TextView label=(TextView)row.findViewById(R.id.text1); label.setText((CharSequence) imageliste.get(position).get("Baslik")); TextView label2=(TextView)row.findViewById(R.id.text2); int boyut =imageliste.get(position).get("Desc").toString().length(); label2.setText((CharSequence) imageliste.get(position).get("Desc").toString().substring(0, (boyut/3)*2)+"..."); ImageView icon=(ImageView)row.findViewById(R.id.img); icon.setImageDrawable((Drawable) imageliste.get(position).get("Resim")); return row; } } public String getURLContent(String url) { try { DefaultHttpClient httpClient = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(url); ResponseHandler&lt;String&gt; resHandler = new BasicResponseHandler(); String page = httpClient.execute(httpGet, resHandler); return page; } catch (ClientProtocolException e) { return ""; } catch (IOException e) { return ""; } } public ArrayList&lt;HashMap&lt;String, Object&gt;&gt; getImageLinks(String strng){ ArrayList&lt;HashMap&lt;String, Object&gt;&gt; myBooks2 = new ArrayList&lt;HashMap&lt;String, Object&gt;&gt;(); String html = getURLContent(strng); Document doc = Jsoup.parse(html); Elements divs = doc.getElementsByClass("postBox"); for (Element div : divs) { Element masthead = div.select("img[src].attachment-post-thumbnail").first(); String linkHref = masthead.attr("src"); Element masthead2 = div.select("h1").first().select("a").first(); String baslik = masthead2.text(); Element masthead3 = div.select("div.textPreview").first().select("p").first(); String desc = masthead3.text(); //Drawable drawable = LoadImageFromWebOperations(); HashMap&lt;String, Object&gt; hm = new HashMap&lt;String, Object&gt;(); hm.put("Resim", LoadImageFromWebOperations(linkHref)); hm.put("Baslik", baslik); hm.put("Desc", desc); myBooks2.add(hm); } return myBooks2; } private Drawable LoadImageFromWebOperations(String url){ try{ InputStream is = (InputStream) new URL(url).getContent(); Drawable d = Drawable.createFromStream(is, "src name"); return d; }catch (Exception e) { System.out.println("Exc="+e); return null; } } public class backgroundLoadListView extends AsyncTask&lt;String, Void, Void&gt; { private ProgressDialog dialog = new ProgressDialog(getActivity()); @Override protected void onPostExecute(Void result) { // TODO Auto-generated method stub // adapter = new MyCustomAdapter( getActivity().getApplicationContext(), R.layout.list, imageliste); //adapter.notifyDataSetChanged(); dialog.dismiss(); } @Override protected void onPreExecute() { // TODO Auto-generated method stub dialog.setMessage("Yükleniyor..."); dialog.show(); } @Override protected Void doInBackground(String... arg) { // TODO Auto-generated method stub imageliste=getImageLinks(arg[0]); return null; } } public class backgroundLoadListView2 extends AsyncTask&lt;Void, Void, Void&gt; { @Override protected void onPostExecute(Void result) { // TODO Auto-generated method stub LayoutInflater inflater = LayoutInflater.from(getActivity()); View view = inflater.inflate(R.layout.customslidingtabhost, null); ListView listView1=(ListView)view.findViewById(R.id.list); //MyCustomAdapter adapter = new MyCustomAdapter(getActivity(), R.layout.list, imageliste); //listView1.setAdapter(adapter); int[] colors = {0xFFFFFFFF, 0xFF87CEEB, 0xFFFFFFFF}; // red for the example listView1.setDivider(new GradientDrawable(Orientation.RIGHT_LEFT, colors)); listView1.setDividerHeight(2); listView1.setBackgroundColor(Color.WHITE); ((PullToRefreshListView) listView1).onRefreshComplete(); } @Override protected void onPreExecute() { // TODO Auto-generated method stub } @Override protected Void doInBackground(Void... params) { // TODO Auto-generated method stub imageliste=getImageLinks("http://www.teknoinfo.net/kategoriler/haberler/teknoloji-haberleri"); return null; } } public static TestFragment newInstance(String content) { TestFragment fragment = new TestFragment(); return fragment; } private String mContent = "???"; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if ((savedInstanceState != null) &amp;&amp; savedInstanceState.containsKey(KEY_CONTENT)) { mContent = savedInstanceState.getString(KEY_CONTENT); } //new backgroundLoadListView().execute("http://www.teknoinfo.net/haberler"); MyCustomAdapter adapter = new MyCustomAdapter( getActivity().getApplicationContext(), R.layout.list, imageliste); View view = inflater.inflate(R.layout.customslidingtabhost, null); final ListView v=(ListView)view.findViewById(R.id.list); /*((PullToRefreshListView) v).setOnRefreshListener(new OnRefreshListener() { public void onRefresh() { // Do work to refresh the list here. new backgroundLoadListView2().execute(); } });*/ int[] colors = {0xFFFFFFFF, 0xFF87CEEB, 0xFFFFFFFF}; // red for the example v.setDivider(new GradientDrawable(Orientation.RIGHT_LEFT, colors)); v.setDividerHeight(2); v.setBackgroundColor(Color.WHITE); v.setAdapter(adapter); ((PullToRefreshListView) v).setOnRefreshListener(new OnRefreshListener() { public void onRefresh() { // Do work to refresh the list here. //new backgroundLoadListView2().execute(); // new backgroundLoadListView().execute("http://www.teknoinfo.net/haberler"); } }); return view; } @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); } @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putString(KEY_CONTENT, mContent); } </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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