1

I'm trying to to open activity within my activity. User clicks button on the left side of the layout and the intent is shown on the right side. How this could be done while keeping the leftside buttons visible? Everytime I tried to start intent, it is opened on top of my layout covering it.

So the logic is same as tarketing HTML link to certain frame, but on android with activities/intents.

Mockup:

http://i.stack.imgur.com/jHqKd.jpg

Update:

I'd like to make this question more specific. If I open intent from my fragment it opens on fullscreen instead of filling only the are of current fragment:

    Button button = (Button) view.findViewById(R.id.button1);
    button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub

            String url = "http://www.google.com";
            Intent google = new Intent(Intent.ACTION_VIEW);
            google.setData(Uri.parse(url));
            getActivity().startActivity(google);
        }
    });

How to open intent from a fragment, so it fills only fragment, not the whole screen?

4

2 回答 2

3

您正在寻找的是片段。可以根据需要轻松添加片段和从活动中分离片段。因此,您基本上需要做的是在单击按钮时添加一个片段,当单击另一个按钮时,您应该删除该片段并添加另一个。

于 2013-08-01T10:38:14.360 回答
0

尝试使用 WebView 的 dis 代码

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_height="wrap_content"
        android:layout_width="wrap_content">

        <Button 
            android:id="@+id/frst_btn"
            android:layout_height="wrap_content"
            android:layout_width="fill_parent"
            android:layout_weight="1"
            android:text="FIRST"/>

        <Button 
            android:id="@+id/second_btn"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:layout_weight="0"
            android:text="SECOND"/>

    </LinearLayout>

    <WebView 
        android:id="@+id/webview"
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"/>

</LinearLayout>

也使用此代码

Button button = (Button) findViewById (R.id.run);
        button.setOnClickListener(new OnClickListener() {           
            @Override
            public void onClick(View v) {
                String url = "URL";

        WebSettings settings = webView.getSettings();
        settings.setBuiltInZoomControls(true);

        webView.setWebViewClient(new Callback());  
        webView.loadUrl(url);          
            }
        });



    private class Callback extends WebViewClient{  

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            return (false);
        }

    }
于 2013-08-01T10:43:41.873 回答