Giter VIP home page Giter VIP logo

Comments (8)

BraisGabin avatar BraisGabin commented on July 2, 2024
  1. I haven't performance comparatives with other components. A Table view doesn't recycle views and TableFixHeaders does it and therefore the last one should be better. I have a TableFixHeader with more than 300 entries and runs like a charm.
  2. No and yes. It is not implemented for all a row (or a column). But if in your adapter you implement the listener in all the cells of a row the result is very similar.
  3. The same as 2.
  4. You can't. If you have 1000 entries you can't measure all of them for performance reasons. And therefore you can't ensure that all the text wraps.

from tablefixheaders.

MariuszGSL avatar MariuszGSL commented on July 2, 2024

Thank you very much for the prompt reply.
That gives me more confidence about using your special component, if you think that point 2 and 3 are feasible.
I will give it a go and will try to implement both point 2 and point 3 OnClick listeners. They are vital to my future application. However I know it is going to be a major challenge, as I am still learning the basics of programming in Android.
I will be using your StyleTable as a template, as I do not require grouping of the records.
Would you be able to suggest where in your SampleTableAdapter would be the best place to add the onClick listeners code ?

I will keep you updated on the progress and will also let you know about the performance of your table grid, once I get the large data set in.
Once again, what you have created is absolutely fantastic.

from tablefixheaders.

BraisGabin avatar BraisGabin commented on July 2, 2024

After line 58:

converView.setOnClickListener(listener);

from tablefixheaders.

MariuszGSL avatar MariuszGSL commented on July 2, 2024

Thank you for a valuable tip.
I have got as far as getting the X,Y coordinates of the clicked cell, using the following code:
public OnClickListener listener = new OnClickListener() {
@OverRide
public void onClick(View v) {
int x = (int) v.getX();
int y = (int) v.getY();

       CharSequence cs = "Cell clicked: X=" + String.valueOf(x)  + ", Y=" + String.valueOf(y);
       Toast.makeText(context, cs, Toast.LENGTH_LONG).show();
    }
};

What I really need is the row (int) and column (int) values for the clicked cell, in order to make further progress.
Would you be so kind to suggest how to get the row and column values for the clicked cell in the above OnClickListener procedure (within your SimpleTableAdapter code).
Thank you in advance.

from tablefixheaders.

MariuszGSL avatar MariuszGSL commented on July 2, 2024

I have got one additional question related to the previous one.
I would like to get the string value of the clicked column header (in order to alter it by adding a sort order arrow).
I have tried the following:

    public void onClick(View v ) {    

            String titleText = null;
            if(v instanceof TextView){
               TextView t = (TextView) v;
               titleText = t.getText().toString();
            };  
        ...   and also:   String titleText = ((TextView) v).getText().toString();

but none of the above methods appear to work.
I would greatly appreciate your suggestion how to extract the text value of the clicked cell.
Kind regards,
Mariusz

from tablefixheaders.

MariuszGSL avatar MariuszGSL commented on July 2, 2024

I have found solution to my last question. Here is the updated code:

public OnClickListener listener = new OnClickListener() {

   @Override
    public void onClick(View v ) {    
       ViewGroup parent = (ViewGroup)v.getParent();
        int x = (int)  v.getX();
        int y = (int)  v.getY();        

        CharSequence cs = ((TextView) v.findViewById(android.R.id.text1)).getText();
        cs = cs + " clicked: X=" + String.valueOf(x)  + ", Y=" + String.valueOf(y);
        Toast.makeText(context, cs, Toast.LENGTH_LONG).show();

        if (y == 0) {       // if clicked on header row cell
                for(int col=0; col<getColumnCount(); col++){
                //TextView tv = (TextView) findViewById(col); 
                //View cell = adapter.getView(row, column);
                View tv = getView(-1, col-1, null, parent);
                setHeaderView(-1, col-1, tv, parent);  
                }
        }   
    }
};

private View setHeaderView(int row, int column, View converView, ViewGroup parent) {
    // if (converView == null) {
    //  converView = inflater.inflate(getLayoutResource(row, column), parent, false);
    // }
    setText(converView, getCellString(row, column) + " ↓");  // change the text for a clicked column header
      // to be done                                       // reset the header text for all other columns back to their original names 
    return converView;
}

However, the remaining issue is how to get the view (ids) for a range of header row cells. Those views would need to be identified, based on the table grid coordinates, starting from cell view (-1, -1) up to (-1, getColumnCount())
The code above (commented out) is not working, as I cannot inflate again the existing cell view. I need to use the already assigned cell views, which will allow me to get the existing strings in those header cells and alter them accordingly.
Any suggestions would be most appreciated.

from tablefixheaders.

BraisGabin avatar BraisGabin commented on July 2, 2024

You can get the clicked cell with this code:

@Override
public View getView(final int row, final int column, View converView, ViewGroup parent) {
    if (converView == null) {
        converView = inflater.inflate(getLayoutResource(row, column), parent, false);
    }
    setText(converView, getCellString(row, column));
    converView.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Toast.makeText(context, "cell in row " + row +" and column "+ column, Toast.LENGTH_SHORT).show();
        }
    });
    return converView;
}

And I don't understend your last problem. If you have problems with the recycled views I recommend you read the documentation of ListViews. TableFixHeaders follows the same pattern.

from tablefixheaders.

MariuszGSL avatar MariuszGSL commented on July 2, 2024

Thank you.

This is exactly what I was trying to achieve.

I can now also solve my header cell editing requirements using the row and column information from the clicked cell.

Your last email was very helpful.

Best regards,

Mariusz

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.