3

在我附加的代码中,我尝试使用两个 Android WebView(webView1 和 webView2)在 webView1 内显示启用了 javaScript 的菜单,并在 webView2 内的 webView1 中显示菜单单击结果的页面。

如代码所示,我正在动态尝试通过计算我自己的初始比例来动态地将 WebView 拟合到目标屏幕,然后在运行时将计算出的比例插入到 WebView 中。

这是我想寻求您帮助的问题...当我单击 webView1 中的菜单项以在 webView2 中显示结果时,额外的水平空白(水平空白的大小与目标屏幕,但水平滚动条大约是 webView2 的宽度)显示在 webView2 中。空白随机出现(即空白有时不出现)。

我尝试添加函数调用以清除 WebViews 缓存。水平空白在 webView2 中出现的频率较低,但问题仍然存在。

有趣的是,这仅发生在 Android 4.0+ 设备中,不会发生在操作系统为 Android 3 及以下的设备中。我们已经使用适用于 Android 4 设备的三星 Galaxy Notes II 和三星 Galaxy Tab 10.1 对此进行了测试。我们在适用于 Android 2.2 设备的华为 Ideos U8150 和适用于 Android 3 设备的无品牌设备上进行了测试。

在编译 Android 项目时,我已将最小 SDK 目标设置为 API 8,将最大 SDK 目标设置为 API 15。

我已经在互联网上(包括 StackOverflow)对这个问题进行了 2 天的广泛研究,但我找不到任何与我的问题上下文相似的帖子。

我想知道如何删除 webView2 中的水平空白。请帮忙。

谢谢。

请参阅下面的代码清单:

package com.xyz.XyzPkg;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;


import android.os.AsyncTask;
import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Gravity;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.ViewGroup;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.ScrollView;
import android.graphics.Bitmap;

public class OpenxyzActivitiesActivity extends Activity implements OnClickListener {

    private final static int ID_BTNBACK = 987654321; 
    private final static int ID_BTNACTIVITY_UI1 = 999977777;
    private final static int ID_BTNACTIVITY_UI2 = 999977776;

    WebView webView1;
    WebView webView2;
    protected String TAG = OpenxyzActivitiesActivity.class.getSimpleName();
    ImageButton btnBack;

    int screenwidth = 0;

    float fOrigWidth1 = 0.0f; //180.0f;
    float fOrigWidth2 = 0.0f; //300.0f;

    float fWeightSum = 0.0f;
    float fWeight1 = 0.0f;
    float fWeight2 = 0.0f;

    float fWindowWidth = 0.0f;
    float fWindowHeight = 0.0f;
    float fWindowDensity = 0.0f;

    float fInitScale1 = 0.0f;
    float fInitScale2 = 0.0f;

    int fViewportSize1 = 0;
    int fViewportSize2 = 0;

    int delta = 0;

    boolean bChosenWidth = false;

    String sUrlBase = "http://test.xyz.com/parents";

    LinearLayout LinearLayout1;

    ImageButton btnActivityUI1;
    ImageButton btnActivityUI2;

    FrameLayout frameLayout0;
    LinearLayout LinearLayout4;

    final int ID_WEBVIEW1 = 987654321;
    @SuppressLint("SetJavaScriptEnabled")
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        webView1 = new WebView(this);
        webView1.setId(ID_WEBVIEW1);
        webView1.getSettings().setJavaScriptEnabled(true);
        webView2 = new WebView(this);

        //new InitTask().execute(new String[]{sUrlBase + "/activities/sendActvtData.php"});
        new InitTask().execute(new String[]{sUrlBase + "/activities/sendActvtData.php"});
    }



    //public class InitThread implements Runnable{
    private class InitTask extends AsyncTask<String, Void, ArrayList<Float> >{
        @Override
        protected void onPostExecute(ArrayList<Float> result) {
            // TODO Auto-generated method stub
            super.onPostExecute(result);

            frameLayout0 = new FrameLayout(getApplicationContext());

            LinearLayout.LayoutParams oFrameLayout0Params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
            frameLayout0.setLayoutParams(oFrameLayout0Params);

            LinearLayout LinearLayout0 = new LinearLayout(getApplicationContext());
            LinearLayout0.setWeightSum(100.0f);

            LinearLayout LinearLayout1 = new LinearLayout(getApplicationContext());


            LinearLayout.LayoutParams oLinearLayout1Params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);

            LinearLayout1.setLayoutParams(oLinearLayout1Params);
            LinearLayout1.setWeightSum(100.0f);

            //BEGIN: Setting up Window Size -- Change Windows Size in UI Thread         
            LayoutParams oLayoutParams = (LayoutParams)LinearLayout1.getLayoutParams();     
            oLayoutParams.width = (int)fWindowWidth;
            oLayoutParams.height = (int)fWindowHeight;
            LinearLayout1.setLayoutParams(oLayoutParams);

            LinearLayout linearLayoutDummyProduct =  new LinearLayout(getApplicationContext());
            android.widget.LinearLayout.LayoutParams linearLayoutDummyProductLayoutParams = new android.widget.LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
            linearLayoutDummyProduct.setLayoutParams(linearLayoutDummyProductLayoutParams);
            oLayoutParams = (LayoutParams)linearLayoutDummyProduct.getLayoutParams();

            LinearLayout linearLayoutDummyProduct2 =  new LinearLayout(getApplicationContext());
            linearLayoutDummyProduct2.setLayoutParams(linearLayoutDummyProductLayoutParams);
            oLayoutParams = (LayoutParams)linearLayoutDummyProduct2.getLayoutParams();


            float fDummy1Weight = 0.0f;
            float fFrameLayoutWeight = 0.0f;
            if (bChosenWidth)
            {
                LinearLayout0.setOrientation(LinearLayout.VERTICAL);
                fDummy1Weight = 100.0f*delta/fWindowHeight;
                linearLayoutDummyProductLayoutParams = new android.widget.LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, fDummy1Weight);

                fFrameLayoutWeight = 100.0f-2*fDummy1Weight;
                oFrameLayout0Params = new android.widget.LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, fFrameLayoutWeight);
                Log.d(TAG, "fDummy1Weight = 100.0f*delta/fWindowHeight;");

            }
            else{
                LinearLayout0.setOrientation(LinearLayout.HORIZONTAL);
                fDummy1Weight = 100.0f*delta/fWindowWidth;
                linearLayoutDummyProductLayoutParams = new android.widget.LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, fDummy1Weight);

                fFrameLayoutWeight = 100.0f-2*fDummy1Weight;
                oFrameLayout0Params = new android.widget.LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, fFrameLayoutWeight);
                Log.d(TAG, "fDummy1Weight = 100.0f*delta/fWindowWidth;");
            }   
            Log.d(TAG, "fDummy1Weight = " + fDummy1Weight);
            Log.d(TAG, "fFrameLayoutWeight = " + fFrameLayoutWeight);
            linearLayoutDummyProduct.setLayoutParams(linearLayoutDummyProductLayoutParams);
            linearLayoutDummyProduct2.setLayoutParams(linearLayoutDummyProductLayoutParams);
            frameLayout0.setLayoutParams(oFrameLayout0Params);
            //END: Setting up Window Size           



            float fWeightSum = LinearLayout1.getWeightSum();
            float fWidthSum = fOrigWidth1 + fOrigWidth2;

            fWeight1 = fOrigWidth1 / fWidthSum * fWeightSum;
            fWeight2 = fOrigWidth2 / fWidthSum * fWeightSum;


            fViewportSize1 = screenwidth * (int)fOrigWidth1 / (int)(fOrigWidth1+fOrigWidth2);
            fViewportSize2 = screenwidth * (int)fOrigWidth2 / (int)(fOrigWidth1+fOrigWidth2);

            Log.d(TAG, "onPostExecute: fViewportSize1=" + fViewportSize1);
            Log.d(TAG, "onPostExecute: fViewportSize2=" + fViewportSize2);

            android.widget.LinearLayout.LayoutParams oLinearLayoutParams1 = new android.widget.LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, fWeight1);
            android.widget.LinearLayout.LayoutParams oLinearLayoutParams2 = new android.widget.LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, fWeight2);
            webView1.setLayoutParams(oLinearLayoutParams1);
            webView2.setLayoutParams(oLinearLayoutParams2);


            oLinearLayoutParams1 = (android.widget.LinearLayout.LayoutParams)webView1.getLayoutParams();
            oLinearLayoutParams2 = (android.widget.LinearLayout.LayoutParams)webView2.getLayoutParams();

            webView2.getSettings().setUseWideViewPort(false);

            LinearLayout1.addView(webView1);
            LinearLayout1.addView(webView2);



            Log.d(TAG, "onPostExecute: fWeightSum=" + fWeightSum);
            Log.d(TAG, "onPostExecute: fWidthSum=" + fWidthSum);
            Log.d(TAG, "onPostExecute: oLinearLayoutParams1.weight=" + oLinearLayoutParams1.weight);
            Log.d(TAG, "onPostExecute: oLinearLayoutParams2.weight=" + oLinearLayoutParams2.weight);      


            webView1.setInitialScale((int)fInitScale1);
            webView2.setInitialScale((int)fInitScale2);

            webView1.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
            webView2.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);

            webView1.setPersistentDrawingCache(ViewGroup.PERSISTENT_NO_CACHE);
            webView1.clearCache(true);
            webView1.clearHistory(); 
            webView1.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
            //webView1.loadUrl(sUrlBase + "/activities/?lang=en");          
            String sWebView1Url = sUrlBase + "/activities/?lang=en&viewport_width="+fViewportSize1 + "&viewport_initial_scale=" + fInitScale1*0.01f;
            webView1.loadUrl(sWebView1Url);
            Log.d(TAG, "onPostExecute(): sWebView1Url: " + sWebView1Url);


            webView1.setWebViewClient(new WebViewClient() { 
                public boolean shouldOverrideUrlLoading(WebView view, String url){
                    //webView1.stopLoading();

                    url = url + "&viewport_width=" + fViewportSize2  + "&viewport_initial_scale=" + fInitScale2*0.01f;

                    Log.d(TAG, "setWebViewClient: CHK000: url: " + url);
                    if (view.getId() == ID_WEBVIEW1)
                    {
                        Log.d(TAG, "ID_WEBVIEW1: " + ID_WEBVIEW1);
                        Log.d(TAG, "WebView1 stopped loading");
                        //view.stopLoading();



                        webView1.setPersistentDrawingCache(ViewGroup.PERSISTENT_NO_CACHE);
                        webView1.clearCache(true);
                        webView1.clearHistory();

                        webView2.setPersistentDrawingCache(ViewGroup.PERSISTENT_NO_CACHE);
                        webView2.clearView();
                        webView2.clearCache(true);
                        webView2.clearHistory(); 
                        Map<String, String> noCacheHeaders = new HashMap<String, String>(2);
                        noCacheHeaders.put("Pragma", "no-cache");
                        noCacheHeaders.put("Cache-Control", "no-cache");
//                      webView2.getSettings().setAppCacheMaxSize(0);
//                      webView2.getSettings().setAppCacheEnabled(false);
                        webView2.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
                        webView2.loadUrl(url, noCacheHeaders);
//                      webView2.loadUrl(url);
                        Log.d(TAG , "shouldOverrideUrlLoading(): fInitScale1: " + fInitScale1);
                        Log.d(TAG , "shouldOverrideUrlLoading(): fInitScale2: " + fInitScale2);        
                        Log.d(TAG , "shouldOverrideUrlLoading(): webView1.getScale(): " + webView1.getScale());
                        Log.d(TAG , "shouldOverrideUrlLoading(): webView2.getScale(): " + webView2.getScale());                     
                        Log.d(TAG, "shouldOverrideUrlLoading(): ((LinearLayout.LayoutParams)webView2.getLayoutParams()).weight: " + ((LinearLayout.LayoutParams)webView2.getLayoutParams()).weight);
                        Log.d(TAG , "shouldOverrideUrlLoading(): url: " + url);

                        webView1.setInitialScale((int)fInitScale1);
                        webView2.setInitialScale((int)fInitScale2);
                    }
                    else
                    {
                        Log.d(TAG, "Other Web View triggered shouldOverrideUrlLoading");
                    }

                    return true; 
                } 

            });

            webView2.setPersistentDrawingCache(ViewGroup.PERSISTENT_NO_CACHE);
            webView2.clearView();
            webView2.clearCache(true);
            webView2.clearHistory(); 
//          Map<String, String> noCacheHeaders = new HashMap<String, String>(2);
//          noCacheHeaders.put("Pragma", "no-cache");
//          noCacheHeaders.put("Cache-Control", "no-cache");
//          webView2.getSettings().setAppCacheMaxSize(0);
//          webView2.getSettings().setAppCacheEnabled(false);
            webView2.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
//          webView2.loadUrl("http://parents.xyz.com/activities/?catg=coloring", noCacheHeaders);
            //webView2.loadUrl(sUrlBase + "/activities/?catg=coloring");
            webView2.loadUrl(sUrlBase + "/activities/?catg=coloring&viewport_width="+fViewportSize2 + "&viewport_initial_scale=" + fInitScale1*0.01f);
            //webView2.getSettings().setTextSize(t)

            frameLayout0.addView(LinearLayout1);

            LinearLayout LinearLayout2 = new LinearLayout(getApplicationContext());
            LinearLayout.LayoutParams oLinearLayout2Params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
            LinearLayout2.setLayoutParams(oLinearLayout2Params);
            LinearLayout2.setWeightSum(100.0f);
            LinearLayout2.setOrientation(LinearLayout.HORIZONTAL);

            frameLayout0.addView(LinearLayout2);

            ImageView btnInvisible0 = new ImageView(getApplicationContext());
            LinearLayout.LayoutParams btnInvisible0Params = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 90.0f);
            btnInvisible0.setLayoutParams(btnInvisible0Params);


            LinearLayout LinearLayout3 = new LinearLayout(getApplicationContext());
            LinearLayout.LayoutParams oLinearLayout3Params = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 10.0f);
            LinearLayout3.setLayoutParams(oLinearLayout3Params);
            LinearLayout3.setWeightSum(100.0f);
            LinearLayout3.setOrientation(LinearLayout.VERTICAL);

            btnBack = new ImageButton(getApplicationContext());
            btnBack.setId(ID_BTNBACK);
            LinearLayout.LayoutParams btnBackParams = new LinearLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, 0, 18.0f);           
            btnBack.setLayoutParams(btnBackParams);
            btnBack.setScaleType(ScaleType.FIT_XY);
            btnBack.post(new Runnable(){
                @Override
                public void run() {
                    // TODO Auto-generated method stub
                    btnBack.setBackgroundDrawable((Drawable)getResources().getDrawable(R.drawable.btn_back));
                }
            });
            btnBack.setOnClickListener(OpenxyzActivitiesActivity.this);

            ImageView btnInvisible1 = new ImageView(getApplicationContext());
            LinearLayout.LayoutParams btnInvisible1Params = new LinearLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, 0, 82.0f);
            btnInvisible1.setLayoutParams(btnInvisible1Params);

            LinearLayout4 = new LinearLayout(getApplicationContext());          
            LinearLayout.LayoutParams oLinearLayout4Params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
            LinearLayout4.setLayoutParams(oLinearLayout4Params);
            LinearLayout4.setWeightSum(100.0f);
            LinearLayout4.setOrientation(LinearLayout.HORIZONTAL);
            LinearLayout4.setOnClickListener(OpenxyzActivitiesActivity.this);

            frameLayout0.addView(LinearLayout4);

            btnActivityUI1 = new ImageButton(getApplicationContext());
            btnActivityUI1.setId(ID_BTNACTIVITY_UI1);
            LinearLayout.LayoutParams btnActivityUI1Params = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 37.5f);           
            btnActivityUI1.setLayoutParams(btnActivityUI1Params);
            btnActivityUI1.setScaleType(ScaleType.FIT_CENTER);
            btnActivityUI1.post(new Runnable(){
                @Override
                public void run() {
                    // TODO Auto-generated method stub
                    btnActivityUI1.setImageDrawable((Drawable)getResources().getDrawable(R.drawable.activityui_300));
                }
            });
            btnActivityUI1.setOnClickListener(OpenxyzActivitiesActivity.this);

            btnActivityUI2 = new ImageButton(getApplicationContext());
            btnActivityUI2.setId(ID_BTNACTIVITY_UI2);
            LinearLayout.LayoutParams btnActivityUI2Params = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 62.5f);           
            btnActivityUI2.setLayoutParams(btnActivityUI2Params);
            btnActivityUI2.setScaleType(ScaleType.FIT_CENTER);
            btnActivityUI2.post(new Runnable(){
                @Override
                public void run() {
                    // TODO Auto-generated method stub
                    btnActivityUI2.setImageDrawable((Drawable)getResources().getDrawable(R.drawable.activityui_500));
                }
            });
            btnActivityUI2.setOnClickListener(OpenxyzActivitiesActivity.this);

            LinearLayout4.addView(btnActivityUI1);
            LinearLayout4.addView(btnActivityUI2);


            LinearLayout3.addView(btnBack);
            LinearLayout3.addView(btnInvisible1);

            LinearLayout2.addView(btnInvisible0);
            LinearLayout2.addView(LinearLayout3);

            LinearLayout0.addView(linearLayoutDummyProduct);
            LinearLayout0.addView(frameLayout0);            
            LinearLayout0.addView(linearLayoutDummyProduct2);


            setContentView(LinearLayout0);

        }

        @Override
        protected ArrayList<Float> doInBackground(String... params) {
            // TODO Auto-generated method stub
            Log.d(InitTask.class.getSimpleName() , "params[0]: " + params[0]);          
            return callHttp(params[0]);         
        }

        private ArrayList<Float> callHttp(String url) {

            ArrayList<Float> alResult = new ArrayList<Float>();

            //BEGIN HTTP Request...
            //String url = "http://parents.xyz.com/activities/sendActvtData.php";
            Log.d(InitTask.class.getSimpleName() , "url: " + url);
            HttpClient httpclient = new DefaultHttpClient();

            // Prepare a request object
            HttpGet httpget = new HttpGet(url); 
            Log.d(TAG , "CHK000");
            // Execute the request
            HttpResponse response;
            String result = "";
            try {
                Log.d(TAG , "CHK010");
                response = httpclient.execute(httpget);
                // Examine the response status
                Log.d(TAG , "CHK020");
                Log.i(TAG,response.getStatusLine().toString());

                Log.d(TAG , "CHK030");
                // Get hold of the response entity
                HttpEntity entity = response.getEntity();
                // If the response does not enclose an entity, there is no need
                // to worry about connection release
                Log.d(TAG , "Is entity null? " + ((entity == null)?"YES":"NO") );

                Log.d(TAG , "CHK040");
                if (entity != null) {

                    // A Simple JSON Response Read
                    InputStream instream = entity.getContent();
                    result= convertStreamToString(instream);
                    // now you have the string representation of the HTML request
                    instream.close();
                }
                Log.d(TAG , "CHK100");

            }
            catch (ClientProtocolException cpe){
                Log.e(TAG , cpe.getMessage());
            }
            catch (IOException ioe){
                Log.e(TAG , ioe.getMessage());
            }
            catch (Exception e) {
                Log.d(TAG , "CHK EXP");
                Log.d(TAG, e.toString());

            }
            //END HTTP Request...

            Log.d(TAG, "http result: " + result);

            String[] ActvData = result.split(",");
            fOrigWidth1 = Float.parseFloat(ActvData[0]);
            fOrigWidth2 = Float.parseFloat(ActvData[1]);

            Log.d(TAG, "fOrigWidth1: " + fOrigWidth1);
            Log.d(TAG, "fOrigWidth2: " + fOrigWidth2);


            //BEGIN: Setting up Window Size -- Calculation
            DisplayMetrics metrics = new DisplayMetrics();
            getWindowManager().getDefaultDisplay().getMetrics(metrics);

            screenwidth = metrics.widthPixels;
            int screenheight = metrics.heightPixels;
            Log.d(TAG, "screenwidth: " + screenwidth);
            Log.d(TAG, "screenheight: " + screenheight);

            //800x480
            float heightFactor = (float)screenheight / 480f;
            float widthFactor = (float)screenwidth / 800f;

            float chosenFactor = 1f;
            bChosenWidth = false;
            if (widthFactor < heightFactor)
            {
                bChosenWidth = true;
                chosenFactor = widthFactor;
            }
            else
            {
                bChosenWidth = false;
                chosenFactor = heightFactor;
            }


            int newHeight = (int)((float)480.0 * (float)chosenFactor);
            int newWidth = (int)((float)800.0 * (float)chosenFactor);
            Log.d(TAG, "heightFactor: " + heightFactor);
            Log.d(TAG, "widthFactor: " + widthFactor);
            Log.d(TAG, "newHeight: " + newHeight);
            Log.d(TAG, "newWidth: " + newWidth);

            delta = 0;
            if (bChosenWidth)
            {
                delta = (screenheight - newHeight) / 2;

            }
            else{
                delta = (screenwidth - newWidth) / 2;
            }
            Log.d(TAG, "delta: " + delta);
            //END: Setting up Window Size -- Calculation

            fWindowWidth = newWidth; 
            fWindowHeight = newHeight; 
            fWindowDensity = (float)metrics.density;


            fWeight1 = fOrigWidth1;
            fWeight2 = fOrigWidth2;
            fWeightSum = fWeight1 + fWeight2;

            Log.d(TAG , "fWeight1: " + fWeight1);
            Log.d(TAG , "fWeight2: " + fWeight2);

            fInitScale1 = 0.0f;
            fInitScale2 = 0.0f;

            fInitScale1 = fInitScale2 = fWindowWidth / fWeightSum * 100;


            Log.d(TAG , "fWindowWidth: " + fWindowWidth);
            Log.d(TAG , "fWindowHeight: " + fWindowHeight);
            Log.d(TAG , "fWindowDensity: " + fWindowDensity);
            Log.d(TAG , "fInitScale1: " + fInitScale1);
            Log.d(TAG , "fInitScale2: " + fInitScale2);


            Log.d(TAG , "CHK200");
            return alResult;
        }



        private String convertStreamToString(InputStream is) {
            /*
             * To convert the InputStream to String we use the BufferedReader.readLine()
             * method. We iterate until the BufferedReader return null which means
             * there's no more data to read. Each line will appended to a StringBuilder
             * and returned as String.
             */
            BufferedReader reader = new BufferedReader(new InputStreamReader(is));
            StringBuilder sb = new StringBuilder();

            String line = null;
            try {
                while ((line = reader.readLine()) != null) {
                    sb.append(line + "\n");
                }
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                try {
                    is.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return sb.toString();
        }


    }



    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        switch(v.getId()){ 
        case ID_BTNBACK:
            Intent myIntent = new Intent();
            setResult(Activity.RESULT_OK, myIntent);
            finish();
            break;
        case ID_BTNACTIVITY_UI1: case ID_BTNACTIVITY_UI2:
            LinearLayout4.setClickable(false);
            frameLayout0.removeView(LinearLayout4);
            break;
        }
    }

}
4

0 回答 0