Question

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

Was it helpful?

Solution

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; 
}} 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top