Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I get item layout from adapter ? #46

Closed
jemmycalak opened this issue Jun 28, 2019 · 7 comments
Closed

How can I get item layout from adapter ? #46

jemmycalak opened this issue Jun 28, 2019 · 7 comments

Comments

@jemmycalak
Copy link

I was try with this script but nothing happen.

View v =adapter.getView(0, null, graphView);
TextView t = v.findViewById(R.id.t1);
t.setText("TEST");

@DennisBlock
Copy link
Contributor

You're using this library in the wrong way. GraphView works similar to how you would use the RecyclerView. Create the adapter with the viewholder pattern. In the viewholder you have your item view, where you get your child views from. If you look in the readme you find an example or look in the sample folder.

@jemmycalak
Copy link
Author

yes, I was do same like you say, my graph is showing,, but I want to custom the node by get item layout from adapter..

Can you show me the simple code to that case ? I was see the sample code but nothing

@DennisBlock
Copy link
Contributor

What do you mean by "custom the node"? If you just want to change your data, you have to change it in the node object inside the graph. Then just call adapter.notifyInvalidated() to update the view.

Setting the data to the views should only be done inside the adapters onBindViewHolder method.

@jemmycalak
Copy link
Author

custom node layout,, not data of node.

I want to change item layout with different way,, not on onBindView,,
Can I do that ?

@DennisBlock
Copy link
Contributor

You can change the item layout in the onCreateViewHolder method, like here:
https://github.com/Team-Blox/GraphView/blob/43dd72340ce08dba9f62cb0c5228a2d56206414c/sample/src/main/java/de/blox/graphview/sample/GraphActivity.java#L47

Create a layout xml for your item and inflate it in this method. For different layouts in one graph you have to implement the getItemViewType and check the view type in onCreateViewHoler.

Like I said earlier, GraphView can be used just like a RecyclerView. You can google your problem and adapt the solution to GraphView or ask on StackOverflow.

@jemmycalak
Copy link
Author

yes,, that is still in onCreateView method, I want to different way, outside OnCreateView. like this:

https://stackoverflow.com/a/54751851

can I do that ?
thank you for your support.

@DennisBlock
Copy link
Contributor

No, this is not possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants