2

iam using Aphid-FlipView-Library to display static html pages using webview.

but while flipping ,(moving) from one page to another iam getting some white frame ,after that second page is normally loading..

can any one help me , how to remove that flash appearance..

public class FlipTextViewFragment extends Fragment {
private FlipViewController flipView;
String[] urls = {"file:///android_asset/Introduction_print.html","file:///android_asset/introduction2.html"};

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    flipView = new FlipViewController(inflater.getContext(), FlipViewController.HORIZONTAL);
    flipView.setAdapter(new adp(getActivity().getApplicationContext()));
    return flipView;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
}
public void setText(String item) {
    flipView.setAdapter(new adp(getActivity().getApplicationContext()));
    }}

then my adapter class is here: package com.example.flipwebview;

 public class adp extends BaseAdapter {
 String[] urls = {"file:///android_asset/Introduction_print.html","file///android_asset/introduction2.html"};
   Context con; 
public adp(Context applicationContext) {
    // TODO Auto-generated constructor stub
    con=applicationContext;
}
    @Override
public int getCount() {
    // TODO Auto-generated method stub
    return urls.length;
}
   @Override
public Object getItem(int position) {
    // TODO Auto-generated method stub
    return position; 
}
   @Override 
public long getItemId(int position) {
    // TODO Auto-generated method stub
    return position;
}
    @Override
public View getView(final int position, View convertView, ViewGroup parent) {
    // TODO Auto-generated method stub
    WebView wv=new WebView(con);
    wv.loadUrl(urls[position]);
return wv; 
}} 

By using my code , i can flip across multiple webviews,but the problem i am getting is when i am halfway flipping the page i cant see my next view,it seems to be a blank page,it gets loaded after i flip my page completely..here is the screen regarding that

enter image description here

vaish
  • 33
  • 4

1 Answers1

0

loadUrl isn't fastest method to render local HTML files. Since they are included in your app you should load their content into String and use loadData method.

http://developer.android.com/reference/android/webkit/WebView.html#loadData%28java.lang.String,%20java.lang.String,%20java.lang.String%29

EDIT:
One more thing. You should use convertView instead of creating new WebView every time you flip.

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    WebView webView = null;
    if (convertView == null)
    {
       webView = new WebView(con);
    } else {
       webView = (WebView) convertView;
    }

    webView.loadUrl(urls[position]);
    return webView; 
}} 
Piotr
  • 1,743
  • 1
  • 26
  • 40
  • Thank you for your quick reply, but still after converting in to load data..i am getting the same thing as previous.and while reading html file from raw folder images are not displaying.. – vaish Feb 11 '13 at 12:58
  • can you please give me the solution for displaying images in html file(which is stored in raw folder) with html content using webview.loaddata(....) – vaish Feb 11 '13 at 13:18
  • You have to add images to 'assets' folder and refer to them from HTML file by filenames. Something like . – Piotr Feb 11 '13 at 13:21
  • 'Here' means where... ? :) – Piotr Feb 11 '13 at 15:26
  • @vaish : Still after using webview.loaddata() , the problem has not solved,it's displaying the samething as previous with webview.loadurl(). – vaish Feb 12 '13 at 05:57