Android Open Source - android-cassowary-layout Cassowary Layouts In List View Activity






From Project

Back to project page android-cassowary-layout.

License

The source code is released under:

Apache License

If you think the Android project android-cassowary-layout listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package no.agens.cassowarylayoutdemo;
/*from   w  w  w  .ja  va 2 s  .com*/
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;

public class CassowaryLayoutsInListViewActivity extends Activity {

    private static final int ITEM_COUNT = 300;
    private static final int ITEM_TYPE_COUNT = 3;
    private static final String LOG_TAG = "CassowaryLayoutsInListViewActivity";

    private class Adapter extends BaseAdapter {

        @Override
        public int getCount() {
            return ITEM_COUNT;
        }

        @Override
        public Object getItem(int position) {
            return new Object();
        }

        @Override
        public int getItemViewType (int position) {
            return getIdFromPosition(position);
        }

        @Override
        public int getViewTypeCount() {
            return ITEM_TYPE_COUNT;
        }

        @Override
        public long getItemId(int position) {
            return getIdFromPosition(position);
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            LayoutInflater inflater = getLayoutInflater();
            View view = convertView;
            if (view == null) {
                view = inflater.inflate(getLayoutIdPosition(position), parent, false);
            }
            return view;
        }

        private int getIdFromPosition(int position) {
            int id = (position % ITEM_TYPE_COUNT);

            Log.d(LOG_TAG, "position " + position + " id " + id);
            return id;
        }

        private int getLayoutIdPosition(int position) {
            int id = getIdFromPosition(position);
            switch (id) {
                case 0:
                    return R.layout.item_stairs;
                case 1:
                    return R.layout.item_squares;
                case 2:
                    return R.layout.activity_chess_board;
                default:
                    throw new RuntimeException("unknown id");
            }
        }
    }

    private Adapter adapter = new Adapter();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_cassowary_layouts_in_list_view);
        ListView listView = (ListView) findViewById(R.id.list_view);
        listView.setAdapter(adapter);
    }

}




Java Source Code List

no.agens.cassowarylayout.ApplicationTest.java
no.agens.cassowarylayout.CassowaryLayout.java
no.agens.cassowarylayout.CassowaryModel.java
no.agens.cassowarylayout.ChildNode.java
no.agens.cassowarylayout.ConstraintParser.java
no.agens.cassowarylayout.ContainerNode.java
no.agens.cassowarylayout.DefaultViewIdResolver.java
no.agens.cassowarylayout.Node.java
no.agens.cassowarylayout.ViewIdResolver.java
no.agens.cassowarylayout.util.CassowaryUtil.java
no.agens.cassowarylayout.util.DimensionParserTest.java
no.agens.cassowarylayout.util.DimensionParser.java
no.agens.cassowarylayout.util.ExpressionTokenizerTest.java
no.agens.cassowarylayout.util.InfixToPostFixTest.java
no.agens.cassowarylayout.util.MeasureSpecUtils.java
no.agens.cassowarylayout.util.TimerUtil.java
no.agens.cassowarylayoutdemo.ApplicationTest.java
no.agens.cassowarylayoutdemo.CassowaryLayoutInLinearLayoutActivity.java
no.agens.cassowarylayoutdemo.CassowaryLayoutMatchParentActivity.java
no.agens.cassowarylayoutdemo.CassowaryLayoutWrapContentActivity.java
no.agens.cassowarylayoutdemo.CassowaryLayoutsInCassowaryLayoutActivity.java
no.agens.cassowarylayoutdemo.CassowaryLayoutsInListViewActivity.java
no.agens.cassowarylayoutdemo.CenterInParentActivity.java
no.agens.cassowarylayoutdemo.CenterViewRelativeToSiblingActivity.java
no.agens.cassowarylayoutdemo.ChessBoardActivity.java
no.agens.cassowarylayoutdemo.DynamicWidthActivity.java
no.agens.cassowarylayoutdemo.ExampleMenuActivity.java
no.agens.cassowarylayoutdemo.FixedAspectRatioDemoActivity.java
no.agens.cassowarylayoutdemo.IntrinsicHeightTextInWrapContentContainerActivity.java
no.agens.cassowarylayoutdemo.LayoutParamsSwitcherActivity.java
no.agens.cassowarylayoutdemo.LinearLayoutInCassowaryLayoutActivity.java
no.agens.cassowarylayoutdemo.ParallaxScrollingActivity.java
no.agens.cassowarylayoutdemo.PreSetupTestActivity.java
no.agens.cassowarylayoutdemo.ProgrammaticDemoActivity.java
no.agens.cassowarylayoutdemo.XmlLayoutDemoActivity.java
no.agens.cassowarylayoutdemo.util.EditRatioDialog.java