S
S
shuhermayer2014-03-15 17:13:56
Android
shuhermayer, 2014-03-15 17:13:56

How to competently organize the output of elements with several attributes from XML according to your template?

It is necessary to display data from the XML file on the screen according to your template, for example:
Element1
attribute 1 (TextView) attribute 2 (Spinner) attribute 3 (icon) [Button] (save changes button)
Element2
attribute 1 (TextView) attribute 2 (Spinner) attribute 3 (icon) [Button] (save changes button)
....
ElementN
attribute 1 (TextView) attribute 2 (Spinner) attribute 3 (icon) [Button] (save changes button)
What is the best way to implement such dynamic output? The ListView does not seem to fit - the entire line is clickable in it, but it is necessary that each element in this line be editable or clickable (Spinner, textView, etc., it doesn’t matter).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
FoxInSox, 2014-03-15
@FoxInSox

ListView does not seem to fit - the entire line is clickable in it

Why do you think so? You don't have to think of anything. The ListView can be anything, including clickable items.
ListView listView = (ListView) findViewById(R.id.listView);
ListAdapter adapter = new ListAdapter() {

  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    return LayoutInflater.from(getApplicationContext()).inflate(R.layout.list_item, null);
  }
  
  @Override public boolean areAllItemsEnabled() {return false;}
  @Override public boolean isEnabled(int position) {return false;}
  @Override public void registerDataSetObserver(DataSetObserver observer) {}
  @Override public void unregisterDataSetObserver(DataSetObserver observer) {}
  @Override public int getCount() {return 20;}
  @Override public Object getItem(int position) {return null;}
  @Override public long getItemId(int position) {return 0;}
  @Override public boolean hasStableIds() {return false;}
  @Override public int getItemViewType(int position) {return 0;}
  @Override public int getViewTypeCount() {return 20;}
  @Override public boolean isEmpty() {return false;}
};

listView.setAdapter(adapter);

Where R.layout.list_item is an xml resource with your buttons, spinners, text fields, etc.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question