Giter VIP home page Giter VIP logo

Comments (10)

BraisGabin avatar BraisGabin commented on July 20, 2024

I really don't understand your problem. All the magic's inside getItemViewType. Reimplement it.

from tablefixheaders.

cchong avatar cchong commented on July 20, 2024

I figured it out, but thanks for the heads up.

from tablefixheaders.

JayeshVarma avatar JayeshVarma commented on July 20, 2024

Hi cchong, I am on same issue can you please elaborate the solution using getItemViewType

from tablefixheaders.

cchong avatar cchong commented on July 20, 2024

Hi Jayesh please take a look at this link to give you an idea of what worked for me. You may need to change it to suit your needs.

from tablefixheaders.

JayeshVarma avatar JayeshVarma commented on July 20, 2024

Thank you Christopher, I have one more question, How we handle touch listener on each list item of the table row? I want to change the color and text of (right movable panel).
I have applied onclicklistener to convert view but it is not working properly. hope you got my question.
thanks!

from tablefixheaders.

cchong avatar cchong commented on July 20, 2024

Hi Jayesh, unfortunately it has been a while since I've used the TableFixHeaders library so I am unable to help you with your specific question. But I imagine you need to play around with the properties to achieve what you're looking for.

from tablefixheaders.

Masterbee212 avatar Masterbee212 commented on July 20, 2024

Hi guys, i need add item onclick in this library. How to make item onclick in tablefixheader.
Thanks !

from tablefixheaders.

BraisGabin avatar BraisGabin commented on July 20, 2024

Please, no ask things in an issue with a diferent topic. Anyway, before you return a view in you adapter you can set an OnClickListener on the view. Something like: converView.setOnClickListener(listener);

from tablefixheaders.

alasari avatar alasari commented on July 20, 2024

I tried to use the way on this link .but, the application stopped with logchat

java.lang.IndexOutOfBoundsException: Index: 10, Size: 10
at java.util.ArrayList.get(ArrayList.java:411)
at app.al.ti.tianappv3.Dashboard.Feagment.FragmentNilai$NexusTypes.get(FragmentNilai.java:201)

I tried to compare my code and i do not find where my mistake, Maybe some one can help me.,.,?

from tablefixheaders.

rajam1215 avatar rajam1215 commented on July 20, 2024

@alasari

please use this code without family row

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.royalways.gnauniversity.R;

import java.util.ArrayList;
import java.util.List;

public class TimeTableAdapter extends BaseTableAdapter {

private class NexusTypes {

    private final List<Nexus> list;

    NexusTypes() {
        list = new ArrayList<Nexus>();
    }

    private int size() {
        return list.size();
    }

    private Nexus get(int i) {
        return list.get(i);
    }
}

private class Nexus {
    private final String[] data;

    private Nexus(String name, String company, String version, String api, String storage, String inches, String ram) {
        data = new String[]{
                name,
                company,
                version,
                api,
                storage,
                inches,
                ram};
    }
}

private Context context;

private final NexusTypes familys;
private final String headers[] = {
        "Name",
        "Company",
        "Version",
        "API",
        "Storage",
        "Size",
        "RAM",
};
private final int[] widths = {
        120,
        100,
        140,
        60,
        70,
        60,
        60,
};
private final float density;

public TimeTableAdapter(Context context) {
    this.context = context;

    familys = new NexusTypes();

    density = context.getResources().getDisplayMetrics().density;

    familys.list.add(new Nexus("Nexus One", "HTC", "Gingerbread", "10", "512 MB", "3.7\"", "512 MB"));
    familys.list.add(new Nexus("Nexus S", "Samsung", "Gingerbread", "10", "16 GB", "4\"", "512 MB"));
    familys.list.add(new Nexus("Galaxy Nexus (16 GB)", "Samsung", "Ice cream Sandwich", "15", "16 GB", "4.65\"", "1 GB"));
    familys.list.add(new Nexus("Galaxy Nexus (32 GB)", "Samsung", "Ice cream Sandwich", "15", "32 GB", "4.65\"", "1 GB"));
    familys.list.add(new Nexus("Nexus 4 (8 GB)", "LG", "Jelly Bean", "17", "8 GB", "4.7\"", "2 GB"));
    familys.list.add(new Nexus("Nexus 4 (16 GB)", "LG", "Jelly Bean", "17", "16 GB", "4.7\"", "2 GB"));
    familys.list.add(new Nexus("Nexus 7 (16 GB)", "Asus", "Jelly Bean", "16", "16 GB", "7\"", "1 GB"));
    familys.list.add(new Nexus("Nexus 7 (32 GB)", "Asus", "Jelly Bean", "16", "32 GB", "7\"", "1 GB"));
    familys.list.add(new Nexus("Nexus 10 (16 GB)", "Samsung", "Jelly Bean", "17", "16 GB", "10\"", "2 GB"));
    familys.list.add(new Nexus("Nexus 10 (32 GB)", "Samsung", "Jelly Bean", "17", "32 GB", "10\"", "2 GB"));
    familys.list.add(new Nexus("Nexus Q", "--", "Honeycomb", "13", "--", "--", "--"));
}

@Override
public int getRowCount() {
    return familys.size();
}

@Override
public int getColumnCount() {
    return 6;
}

@Override
public View getView(int row, int column, View convertView, ViewGroup parent) {
    final View view;
    switch (getItemViewType(row, column)) {
        case 0:
            view = getFirstHeader(row, column, convertView, parent);
            break;
        case 1:
            view = getHeader(row, column, convertView, parent);
            break;
        case 2:
            view = getFirstBody(row, column, convertView, parent);
            break;
        case 3:
            view = getBody(row, column, convertView, parent);
            break;
        default:
            throw new RuntimeException("wtf?");
    }
    return view;
}

private View getFirstHeader(int row, int column, View convertView, ViewGroup parent) {
    if (convertView == null) {
        LayoutInflater inflater = LayoutInflater.from(context);
        convertView = inflater.inflate(R.layout.item_table_header_first, parent, false);
    }
    ((TextView) convertView.findViewById(android.R.id.text1)).setText(headers[0]);
    return convertView;
}

private View getHeader(int row, int column, View convertView, ViewGroup parent) {
    if (convertView == null) {
        LayoutInflater inflater = LayoutInflater.from(context);
        convertView = inflater.inflate(R.layout.item_table_header, parent, false);
    }
    ((TextView) convertView.findViewById(android.R.id.text1)).setText(headers[column + 1]);
    return convertView;
}

private View getFirstBody(int row, int column, View convertView, ViewGroup parent) {
    if (convertView == null) {
        LayoutInflater inflater = LayoutInflater.from(context);
        convertView = inflater.inflate(R.layout.item_table_first, parent, false);
    }
    convertView.setBackgroundResource(row % 2 == 0 ? R.drawable.bg_table_color1 : R.drawable.bg_table_color2);
    ((TextView) convertView.findViewById(android.R.id.text1)).setText(getDevice(row).data[column + 1]);
    return convertView;
}

private View getBody(int row, int column, View convertView, ViewGroup parent) {
    if (convertView == null) {
        LayoutInflater inflater = LayoutInflater.from(context);
        convertView = inflater.inflate(R.layout.item_table, parent, false);
    }
    convertView.setBackgroundResource(row % 2 == 0 ? R.drawable.bg_table_color1 : R.drawable.bg_table_color2);
    ((TextView) convertView.findViewById(android.R.id.text1)).setText(getDevice(row).data[column + 1]);
    return convertView;
}

@Override
public int getWidth(int column) {
    return Math.round(widths[column + 1] * density);
}

@Override
public int getHeight(int row) {
    final int height;
    if (row == -1) {
        height = 35;
    } else {
        height = 45;
    }
    return Math.round(height * density);
}

@Override
public int getItemViewType(int row, int column) {
    final int itemViewType;
    if (row == -1 && column == -1) {
        itemViewType = 0;
    } else if (row == -1) {
        itemViewType = 1;
    } else if (column == -1) {
        itemViewType = 2;
    } else {
        itemViewType = 3;
    }
    return itemViewType;
}

private Nexus getDevice(int row) {
    return familys.get(row);
}

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

i just see your problem, I hope it will help you

from tablefixheaders.

Related Issues (20)

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.