主/细节流程

时间:2015-02-24 09:27:22

标签: java android android-layout android-fragments master-detail

我是Android应用开发的新手 我有一个关于Master Detail Flow Example的问题 那么可以修改任何"布局"或"其他观点"而不是显示" WebView"如何? 谢谢你

这是我的DummyContent.java

package com.iris.baron.mytopap.dummy;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* Helper class for providing sample content for user interfaces created by
* Android template wizards.
* <p/>
* TODO: Replace all uses of this class before publishing your app.
*/
public class DummyContent {

/**
 * An array of sample (dummy) items.
 */
public static List<DummyItem> ITEMS = new ArrayList<DummyItem>();

/**
 * A map of sample (dummy) items, by ID.
 */
 public static Map<String, DummyItem> ITEM_MAP = new HashMap<String,    
 DummyItem>();

static {
    // Add 3 sample items.
    addItem(new DummyItem("1", "Item 1", "https://www.youtube.com/watch?  
    v=cdxJQFXsxXQ"));
    addItem(new DummyItem("2", "Item 2", "http://go.microsoft.com/fwlink/?
    LinkId=54729"));
    addItem(new DummyItem("3", "Item 3",       
    "http://www.maxis.com.my/personal/mobile/mms_services/index_mms.asp"));
    }

private static void addItem(DummyItem item) {
    ITEMS.add(item);
    ITEM_MAP.put(item.id, item);
}

/**
 * A dummy item representing a piece of content.
 */
public static class DummyItem {
    public String id;
    public String content;
    public String url;

    public DummyItem(String id, String content, String Url) {
        this.id = id;
        this.content = content;
        this.url = Url;
    }

    @Override
    public String toString() {
        return content;
    }
}

}`

这是我的ItemDetailFragment.java

package com.iris.baron.mytopap;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;



import com.iris.baron.mytopap.dummy.DummyContent;

 /**
 * A fragment representing a single Item detail screen.
* This fragment is either contained in a {@link ItemListActivity}
* in two-pane mode (on tablets) or a {@link ItemDetailActivity}
* on handsets.
*/
public class ItemDetailFragment extends Fragment {

/**
 * The fragment argument representing the item ID that this fragment
 * represents.
 */
public static final String ARG_ITEM_ID = "item_id";

/**
 * The dummy content this fragment is presenting.
 */
private DummyContent.DummyItem mItem;

/**
 * Mandatory empty constructor for the fragment manager to instantiate the
 * fragment (e.g. upon screen orientation changes).
 */
public ItemDetailFragment() {
}

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (getArguments().containsKey(ARG_ITEM_ID)) {
        // Load the dummy content specified by the fragment
        // arguments. In a real-world scenario, use a Loader
        // to load content from a content provider.
        mItem =    
DummyContent.ITEM_MAP.get(getArguments().getString(ARG_ITEM_ID));
    }
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_item_detail,    
container, false);

    // Show the dummy content as text in a TextView.
    if (mItem != null) {
        ((WebView)    
rootView.findViewById(R.id.Web_detail_area)).loadUrl(mItem.url);
    }

    return rootView;
}
}

0 个答案:

没有答案