GithubHelp home page GithubHelp logo

lerist / nodeflow Goto Github PK

View Code? Open in Web Editor NEW

This project forked from telenav/nodeflow

0.0 3.0 0.0 1.27 MB

NodeFlow is a library that makes visualizing hierarchical content easier.

License: Other

Java 100.00%

nodeflow's Introduction

Download Android Arsenal

NodeFlow

NodeFlow is an Android library that provides a simple way to visualize hierarchical content. Perfect for displaying items that are organized in categories / subcategories.

alt tag

#Requirements Android 4.0+ (Ice Cream Sandwich and later)

#Using NodeFlow

###Step 1 Add the following line to the dependencies section of your build.gradle file

compile 'com.telenav.nodeflow:nodeflow:0.1.2'

###Step 2 Extend NodeFlowLayout class and implement abstract methods

public class MyFlow extends NodeFlowLayout {

...

    //define root node and populate it with data
    Node<String> root = Node.get("root").addChildren(Arrays.asList("child1", "child2", "child3"));

    @Override
    protected Node<?> getRootNode() {
        return root;
    }

    @Override
    protected View getContentView(Node<?> node) {
        //inflate view
        ViewGroup v = (ViewGroup) LayoutInflater.from(getContext()).inflate(R.layout.content, this, false);
        //populate with content
        ((TextView) v.findViewById(R.id.content_title)).setText(node.getData());
        return v;
    }

    @Override
    protected View getHeaderView(Node<?> node) {
        //inflate view
        ViewGroup v = (ViewGroup) LayoutInflater.from(getContext()).inflate(R.layout.header, this, false);
        //populate with content
        ((TextView) v.findViewById(R.id.list_item_text)).setText(node.getData());
        return v;
    }
}

###Step 3 Add extended view to a layout

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

    <com.yourpackage.MyFlow
        android:id="@+id/nodeFlow"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
</RelativeLayout>

###Step 4 (Optional) Set node change listener & animation duration

 MyFlow nodeFlow = ((MyFlow) findViewById(R.id.nodeFlow));
 nodeFlow.setNodeChangeListener(new OnActiveNodeChangeListener() {...});
 nodeFlow.setAnimationDuration(500);

#Sample For a more detailed example check the demoapp module.

#License Apache License, Version 2.0

nodeflow's People

Contributors

dimatim avatar

Watchers

James Cloos avatar Lerist avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.