Best way to display large amounts of text?

I currently have a list and you want to display a large amount of text after the list item has been clicked. The amount of text will vary depending on the selected list item, ranging from paragraph to several paragraphs.

I am still very Android noob, so any tutorials you know about this are relevant to your answer.

Thank.

+3
source share
2 answers

The specifics is how you want your application to look and feel, but I would say that you would not go wrong with a textView with wrap_content for the height and width nested in the scroll view.

, , , , .

+2

, , ListView , .

( , ), .

Pro: ! .

Con:

, , .

:

// bind your adapter here from database or wherever
String[] Columns = { "_id", "Name", "Description" };
    int[] ItemIDs = { R.id.lbl_ID, R.id.lbl_Name, R.id.lbl_Description };
    SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.item, cursor, Columns, ItemIDs);


ListView list_list= (ListView)findViewById(R.id.list);
list_list.setAdapter(adapter);

list.setOnItemClickListener(new OnItemClickListener(){
            @Override
            public void onItemClick(AdapterView parent, View view, int position, long id)
            {
                try
                {

                    Intent i = new Intent(getBaseContext(), ViewItemDetail.class);

                    i.putExtra("ID", ID);
                            // any other data you need to pass on to your view here.  ID should let you select from a database or however you are pulling data
                    startActivity(i);
                }
                catch(Exception ex)
                {
                    Log.println(1, "item-click-event", ex.getMessage());
                }
            }
        });


 // Then in your activity to get intent data:
 Bundle extras = getIntent().getExtras();
 if(extras !=null)
 {
     string ID = extras.getString("ID");
 }
0

Source: https://habr.com/ru/post/1771369/


All Articles