Library and example project on how to use the UITableView component

Overview

UITableView for Android

UITableView UITableView UITableView

Usage

Installation

Android Studio

  1. Paste or clone this library into the /libs folder, in the root directory of your project. Create a new folder: /libs if not already present. (This step is not required - only for keeping cleaner project structure)

  2. Edit settings.gradle by adding the library. You have also define a project directory for the library. Your settings.gradle should look like below:

    include ':app', ':UITableView'
    project(':UITableView').projectDir = new File('libs/UITableView')
    
  3. In app/build.gradle add the UITableView library as a dependency:

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.android.support:appcompat-v7:21.0.3'
        compile project(":UITableView")
    }
    
  4. Sync project, clean and build. You can use the UITableView as part of your project now.

Eclipse

Before you can add a UITableView to your application, you must first add a library reference:

  1. Clone or download a copy of the library
  2. Import the library into Eclipse: File menu -> Import -> Existing Project into Workspace
  3. Open your application's project properties and add a library reference to "UITableView"

Using UITableView in your project

Defining your layout

<br.com.dina.ui.widget.UITableView 
    android:id="@+id/tableView" 
    style="@style/UITableView" />

Working on your activity

public class Example1Activity extends Activity {    
	UITableView tableView;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);        
        tableView = (UITableView) findViewById(R.id.tableView);        
        createList();        
        Log.d("Example1Activity", "total items: " + tableView.getCount());        
        tableView.commit();
    }

    private void createList() {
    	CustomClickListener listener = new CustomClickListener();
    	tableView.setClickListener(listener);
    	tableView.addBasicItem("Example 1", "Summary text 1");
    	tableView.addBasicItem("Example 2", "Summary text 2");
    	tableView.addBasicItem("Example 3", "Summary text 3");
    	tableView.addBasicItem("Example 4", "Summary text 4");
    }

    private class CustomClickListener implements ClickListener {
		@Override
		public void onClick(int index) {
			Toast.makeText(Example1Activity.this, "item clicked: " + index, Toast.LENGTH_SHORT).show();
		}    	
    }    
}

UITableViewActivity

In order to use the default list you can extend the UITableViewActivity, a simple example can be found in the source code below:

public class ExampleActivity extends UITableViewActivity {	

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        CustomClickListener listener = new CustomClickListener();
        getUITableView().setClickListener(listener);
    }

    private class CustomClickListener implements ClickListener {	
		@Override
		public void onClick(int index) {
			Toast.makeText(ExampleActivity.this, "item clicked: " + index, Toast.LENGTH_SHORT).show();
		}	    	
    }

	@Override
	protected void populateList() {
		getUITableView().addItem("Example 1", "Summary text 1");
		getUITableView().addItem("Example 2", "Summary text 2");
		getUITableView().addItem("Example 3", "Summary text 3");
		getUITableView().addItem("Example 4", "Summary text 4");
		getUITableView().addItem("Example 5", "Summary text 5");		
	}	    
}

In this example you don't even need to care about the xml since the UITableViewActivity is using a default layout template the only displays the list in the screen. It is pretty mych the same list you are seeing in the screenshot provided at the beginning of this explanation.

UIButton

<LinearLayout
	android:orientation="vertical"
	android:layout_width="fill_parent"  
	android:layout_height="fill_parent">	

		<br.com.dina.ui.widget.UIButton
			android:layout_width="fill_parent"  
			android:layout_height="fill_parent"
			android:padding="10dip"
			ui:title="some title one"/>

		<br.com.dina.ui.widget.UIButton
			android:layout_width="fill_parent"  
			android:layout_height="fill_parent"
			ui:title="some title two"
			ui:subtitle="some subtitle two"
			android:padding="10dip" />	

		<br.com.dina.ui.widget.UIButton
			android:layout_width="fill_parent"  
			android:layout_height="fill_parent"
			ui:title="some title three"
			ui:subtitle="with image"
			ui:image="@drawable/search_image"
			android:padding="10dip"/>    			    		
</LinearLayout>

Customization

UITableView is an Android Library Project and all its resources will be merged into the referring project. So, in order tu customize the colors of the UITableView and its elements, you need to create the same resources on your own project and this resources will be before the default values provided by the library project.

If you don't like the default colors that is defined in the colors.xml file simply override the default values in the main projects colors.xml file. These are the keys you need to work on to have your customized UITableView working.

<?xml version="1.0" encoding="utf-8"?>
<resources>	
    <!-- LIST BORDER COLOR -->
    <color name="rounded_container_border">#ffb7babb</color>

    <!-- ITEM BACKGROUND COLOR - STATE - DEFAULT -->
    <color name="base_start_color_default">#FFFFFF</color>
    <color name="base_end_color_default">#FFFFFF</color>

    <!-- ITEM BACKGROUND COLOR - STATE - PRESSED -->
    <color name="base_start_color_pressed">#ff3590c4</color>
    <color name="base_end_color_pressed">#ff2570ba</color>

    <!-- ITEM TEXT COLORS - STATES - PRESSED AND DEFAULT -->
    <color name="text_color_default">#000000</color>
    <color name="text_color_pressed">#ffffff</color>			
</resources> 

Example

UITableView UITableView

The theme above was created using the following set of colors:

<resources>
	<color name="rounded_container_border">#50b7babb</color>
	<color name="base_start_color_default">#B0FFFFFF</color>
    <color name="base_end_color_default">#B0FFFFFF</color>
	<color name="base_start_color_pressed">#B03590c4</color>
    <color name="base_end_color_pressed">#B02570ba</color>
    <color name="text_color_default">#000000</color>
    <color name="text_color_pressed">#ffffff</color>   
</resources>

Android applications using it

Contributions

Functionallity improvements and performance enhancements are always welcome. Feel free to fork and apply your changes.

TODO list

  • Hability to let the user define the custom layout for the item
  • Hability to create Items that expand/collapse a set of items

Other Android Libraries

Use these libraries also to get a better UI for your android application

License

Copyright (c) 2011 [Thiago Locatelli] - "thiago:locatelli$gmail:com".replace(':','.').replace('$','@')

Licensed under the Apache License, Version 2.0

Comments
  • Cant click to custom item

    Cant click to custom item

    Hi.

    When i use this code:

    LayoutInflater mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); RelativeLayout view = (RelativeLayout) mInflater.inflate(R.layout.custom_view, null); ViewItem viewItem = new ViewItem(view); getUITableView().addViewItem(viewItem);

    when i click this button, i cant go to onClick(int index)

    But when i use getUITableView().addBasicItem , i can handle the click

    Help me please!

    Regards

    opened by ZuzooVn 7
  • No resource identifier found

    No resource identifier found

    When I try to add a UIButton to my layout i get the fallowing error:

    no resource identifier found for attribute "title" in package br.com.dina.ui

    Thats because i'm using your project as a library project. I'm having problem with the xml namaspace.

    See this: http://devmaze.wordpress.com/2011/05/22/the-case-of-android-libraries-and-custom-xml-attributes-part-2/

    Edit: see the solution here http://stackoverflow.com/a/8292194/1120126

    opened by osrl 6
  • Length of Titles in the TableView

    Length of Titles in the TableView

    Hello. Ive got a Problem. I have very long names which I like to set in the TableView. But it seems that the height of each Tablerow is fixed. So if the Title is too long it adds 3 dots at the end(e.g. ABCDEFGHIJKLM...) But I want it to be shown completely. How can I archive this?

    Thanks

    opened by rashiq 4
  • .addBasicItem() doesn't support Drawable

    .addBasicItem() doesn't support Drawable

    Is there any chance you could add support for a direct Drawable in the .addBasicItem() function? since I'm downloading drawables during run-time and can't assign them to the resources though.

    thanks a lot

    opened by yuvalbar84 2
  • Eclipse Doesn't Recognise It As An Android Library!

    Eclipse Doesn't Recognise It As An Android Library!

    I couldn't include the project as a library in my project because Eclipse imported it as a general project. I tried to change the project nature to android but I ended up with a messy-structured library that has errors Eclipse couldn't identify!

    opened by iturki 2
  • Add method to retrieve any view from any row for the UITableView

    Add method to retrieve any view from any row for the UITableView

    I need to add a method that will allow the user to get any view from any row within the view. For example, if you want to get the imageview fro the row 10, you will be get by doing this: getView(10, R.id.image), this wil return a view that needs to be casted with ImageVew.

    Since the user can define its own custom view as a tablw row, the best approach I could find was this one, so the user will be able to get any view.

    public View getView(int row, int viewId);

    opened by thiagolocatelli 2
  • Does this still work?

    Does this still work?

    This repository hasn't been updated since 2015 (from what I can see) and none of the example screenshots seem to be working anymore, however it is still the most starred repo for iOS style uitableviews in android.

    I'm curious if it still works properly with the latest version of android, before I start digging into it.

    opened by nathan-fiscaletti 1
  • multiple-selection at the same time is allowed with fingers!

    multiple-selection at the same time is allowed with fingers!

    if there is more than one row in the tableview, touches on each row can trigger its onClick event at the same time. Should it be triggered exclusively, only for the first touch?

    opened by johnny-cao 0
  • Update / insert table

    Update / insert table

    Is it possible to update uitableview dynamicly? I want to insert a row to it with a button but couldnt achieve it! I mean something like : tableview.insertview ("text", insert position) (or anything similar to it )

    opened by santral06 0
  • Problem with build with Android Studio

    Problem with build with Android Studio

    Hi,

    I imported whole project as module and added it on settings to my project. But when I try to build app im getting error:

    D:!AndroidStudioProjects\PharmaAppWL\app\build\intermediates\exploded-aar\com.google.android.gms\play-services\6.5.87\res\values\wallet_colors.xml Error:Attribute "title" has already been defined Error:Attribute "subtitle" has already been defined

    Error:Execution failed for task ':app:processDebugResources'.

    com.android.ide.common.internal.LoggedErrorException: Failed to run command: D:\Android Studio SDK\build-tools\21.1.2\aapt.exe package -f --no-crunch -I D:\Android Studio SDK\platforms\android-21\android.jar -M D:!AndroidStudioProjects\PharmaAppWL\app\build\intermediates\manifests\full\debug\AndroidManifest.xml -S D:!AndroidStudioProjects\PharmaAppWL\app\build\intermediates\res\debug -A D:!AndroidStudioProjects\PharmaAppWL\app\build\intermediates\assets\debug -m -J D:!AndroidStudioProjects\PharmaAppWL\app\build\generated\source\r\debug -F D:!AndroidStudioProjects\PharmaAppWL\app\build\intermediates\res\resources-debug.ap_ --debug-mode --custom-package ie.return2sender.pharmaappwl -0 apk --output-text-symbols D:!AndroidStudioProjects\PharmaAppWL\app\build\intermediates\symbols\debug Error Code: 1 Output: D:!AndroidStudioProjects\PharmaAppWL\app\build\intermediates\res\debug\values\values.xml:171: error: Attribute "title" has already been defined D:!AndroidStudioProjects\PharmaAppWL\app\build\intermediates\res\debug\values\values.xml:171: error: Attribute "subtitle" has already been defined

    How I can fix this error?

    opened by R2SAndroid 0
  • Example project is not working.

    Example project is not working.

    I am new to android. Imported Example project in eclipse. Getting some errors about Styles. Specifically style/content_page_large_text missing in custom_view.xml and some more similar errors. I think you have to include style folder. Last commit was 3 years ago. So something may has deprecated. Waiting for your reply.

    opened by alok-rao 2
Owner
Thiago Locatelli
Software engineer. Skydiver. Soccer fan. Passionate about coding and learning new technologies.
Thiago Locatelli
[] A fast PDF reader component for Android development

This project is no longer maintained. You can find a good replacement here, which is a fork relying on Pdfium instead of Vudroid/MuPDF for decoding PD

Joan Zapata 2.8k Dec 16, 2022
(Deprecated) A custom view component that mimics the new Material Design Bottom Navigation pattern.

BottomBar (Deprecated) I don't have time to maintain this anymore. I basically wrote the whole library in a rush, without tests, while being a serious

Iiro Krankka 8.4k Dec 29, 2022
A tinder like swipeable card stack component

AndroidSwipeableCardStack Change log: provide option to infinitly swipe in a loop card rotation setting card gravity setting undo animation Thanks for

wenchao jiang 824 Nov 10, 2022
A backport of the SwitchPreference component that was introduced on Android 4 (ICS / level 14). This port works on Android 2.1+ (Eclair MR1 / level 7).

Android Switch Preference Backport A backport of the SwitchPreference component that was introduced on Android 4 (ICS / level 14). This port works on

Benoit Lubek 498 Dec 29, 2022
Component Box - a multiplatform server-driven UI framework

Component Box · Component Box is a multiplatform server-driven UI framework. Learn how to use Component Box in your project. Installation implementati

Dropbox 216 Dec 31, 2022
Wizard Pager is a library that provides an example implementation of a Wizard UI on Android, it's based of Roman Nurik's wizard pager (https://github.com/romannurik/android-wizardpager)

Wizard Pager Wizard Pager is a library that provides an example implementation of a Wizard UI on Android, it's based of Roman Nurik's wizard pager (ht

Julián Suárez 520 Nov 11, 2022
Wizard Pager is a library that provides an example implementation of a Wizard UI on Android

Wizard Pager is a library that provides an example implementation of a Wizard UI on Android, it's based of Roman Nurik's wizard pager.

Julián Suárez 520 Nov 11, 2022
⚡️A highly customizable, powerful and easy-to-use alerting library for Android.

Flashbar A highly customizable, powerful and easy-to-use alerting library for Android. Specs This library allows you to show messages or alerts in you

Aritra Roy 1.7k Dec 7, 2022
Useful library to use custom fonts in your android app

EasyFonts A simple and useful android library to use custom fonts in android apps without adding fonts into asset/resource folder.Also by using this l

Vijay Vankhede 419 Sep 9, 2022
A small, easy to use android library for implementing flipping between views as seen in the popular Flipboard application

FlipView About This library is made to be very easy to use and at the same time be feature complete. With only a few lines of code you can have a flip

Emil Sjölander 924 Nov 10, 2022
A simple, customizable and easy to use swipeable view stack for Android.

SwipeStack A simple, customizable and easy to use swipeable view stack for Android. QuickStart Include the Gradle dependency dependencies { compil

Frederik Schweiger 1.5k Dec 30, 2022
A color picker and a color preference for use in Android applications.

HSV-Alpha Color Picker for Android This library implements a color picker and a color preference for use in Android applications. Features I couldn't

Martin Stone 279 Nov 26, 2022
A file/directory-picker for android. Implemented as a library project.

Note: avoid using as SD-card file picker on Kitkat+ In Kitkat or above, use Android's built-in file-picker instead. Google has restricted the ability

Jonas Kalderstam 711 Dec 27, 2022
A standalone library project for certificate pinning on Android.

Android Pinning AndroidPinning is a standalone Android library project that facilitates certificate pinning for SSL connections from Android apps, in

Moxie Marlinspike 597 Dec 23, 2022
This project created just for help developer who want to and ability of read VISA, UNION PAY, HUMO, ATTO and some other cards data read.

If you enjoy my content, please consider supporting what I do. Thank you. By me a Coffee To get a Git project into your build: Step 1. Add the JitPack

Fozilbek Imomov 1 Oct 15, 2022
Hi,Developer,Welcome to use SuperTextView !

GitAds Hello, Developer!Welcome to use SuperTextView English | 中文 Hi,Developer,Welcome to use SuperTextView ! Thank you and tens of thousands of Andro

CoorChice 3.3k Dec 30, 2022
A lovely snail,You can use it as a seekbar or progressbar.

SnailBar A lovely ,you can use it as a seekbar or progressbar. Helixbar design by Davlikanoff.This is his words: Hi Guys! This 18 seconds long animati

CJJ 527 Jun 10, 2022
Step by step,just use HorizontalStepView,VerticalStepView. step indicator,flow indicator,timeline,order process,express status

StepView Step by step. Step indicator. Flow indicator。 snapshot like this:HorizontalStepView like this also like this:VerticalStepView Yeah,I am not w

baoyachi. Aka Rust Hairy crabs 4.1k Dec 30, 2022