Reputation: 1255
Is there a view in android, that can store one object and display the object's toString() return value like a TextView?
Or do I have to mimic the behaviour in taking a ListView and ensure that only one item is in its adapter?
I need this, because I use drag & drop to move objects around and I need a view, that can display and store one of the objects.
Thank you!
Upvotes: 0
Views: 43
Reputation: 22637
yes, there is such a view and you already mentioned it. it's called TextView
, and you'd use it like this,
TextView tv = (TextView)findObjectById(R.id.tv);
tv.setText(myObject.toString());
if you don't like like that, extend TextView like this,
class ToStringView extends TextView {
...
public void setObject(Object o) { setText(o.toString()); }
}
Upvotes: 0
Reputation: 9117
There is no such view. Depending on your requirements, you have to implement this functionality.
Upvotes: 1