如果有人熟悉C# 的win编程的话,可能知道,在C#中自定义一个控件很方便,直接在设计器设计,设计完之后,可以直接拖到另外一个控件或者窗口上。
为什么android就这么难啊..

解决方案 »

  1.   

    setContentView实际上是window的方法, activity只是包了一下:
        /**
         * Set the activity content to an explicit view.  This view is placed
         * directly into the activity's view hierarchy.  It can itself be a complex
         * view hierarhcy.
         * 
         * @param view The desired content to display.
         */
        public void setContentView(View view) {
            getWindow().setContentView(view);
        }你要显示你的widget,可以依附一个window,然后 
    setContentView(yourWidget)
    可以参考videoView使用的MediaController。
    不过这玩意得在源码上使用,因为SDK上
    com.android.internal.policy.PolicyManager;
    没有开放出来, 这一般应该用不到。至于你的问题1,
    你可以在你的SimpleAdapter的每个item上绑定一个xml文件啊, xml文件里面随便怎么layout给你个源码的例子:    protected void updateList() {
            setListAdapter(new SimpleAdapter(this,
                    getData(),
                    android.R.layout.simple_list_item_1,
                    new String[] {"title"},
                    new int[] {android.R.id.text1}));
            String title = mPath; //.substring(mBaseLength-11); // show the word LayoutTests
            setTitle(title);
            getListView().setSelection(mFocusIndex);
        }SimpleAdapter 的介绍:
    public SimpleAdapter (Context context, List<? extends Map<String, ?>> data, int resource, String[] from, int[] to) 
    Since: API Level 1 ConstructorParameters
    context  The context where the View associated with this SimpleAdapter is running 
    data  A List of Maps. Each entry in the List corresponds to one row in the list. The Maps contain the data for each row, and should include all the entries specified in "from" 
    resource  Resource identifier of a view layout that defines the views for this list item. The layout file should include at least those named views defined in "to" 
    from  A list of column names that will be added to the Map associated with each item. 
    to  The views that should display column in the "from" parameter. These should all be TextViews. The first N views in this list are given the values of the first N columns in the from parameter. 你parser好的值放在data中,
    按照from的方式,往 to 中对应的 view ID的view中显示。