So, I am making this application. The application analyzes the website, or more specifically, the vbulletin-board. When I parse a thread in a forum, I split it so that when I parse every post in that thread, I get the actual contents of the message in sections like this, and I store the sections in the correct order in the array:
[Plain text]
[Quote from somebody]
[Plain text]
[Another quote]
[Another quote again]
[Some more plain text]
However, the message can be organized in any order, as you probably know, and can consist of more or fewer sections than in the example, and it also does not need to have quotation marks, or it can be just or a few quotation marks. Everything is possible.
When I list messages in my application, I use ListView. Each line of this list will always consist of a heading and any combination of the previously mentioned sections.
The way I thought about doing this after I worked on it a bit was to have one “basic layout” with only a layout in one XML file and a separate layout for each section, stored in a separate XML file and each call to getView () in my adapter, look at the message at this position in my "Post-list", and then scroll through the sections in this particular message and inflate the new "Quote-layout", for each section of the quote stored in the message, and inflate "Plain-text-layout" for each text section in the message. And for each of them, I fill out all the content that belongs to this post.
, , ? , , View, getView(), , getView().. , getView() .
, getView() :
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
view = mInflater.inflate(R.layout.forum_post,null);
View header = mInflater.inflate(R.layout.post_header_layout, null);
View message = mInflater.inflate(R.layout.post_text_layout, null);
View quote = mInflater.inflate(R.layout.post_quote_layout, null);
((ViewGroup)view).addView(header);
((ViewGroup)view).addView(message);
((ViewGroup)view).addView(quote);
return view;
}
// , .
- LinearLayout
, , - RelativeLayouts TextViews ImageView.
,
, .., Quote.
, , , , , , , .
http://s14.postimg.org/rizid8q69/view.png
? , .