当内容更多在android中时,如何调整特定列表视图的高度?

时间:2022-09-25 18:31:05

This is my code to display the content from firebase. But when the content is more, '..' will be displayed as shown in the image. How do I make it to adjust the height automatically and display the full content instead of ..?

这是我显示firebase内容的代码。但是当内容更多时,将显示“..”,如图所示。如何使其自动调整高度并显示完整内容而不是..?

Screen-shot of the activity

屏幕截图的活动

当内容更多在android中时,如何调整特定列表视图的高度?

Public class InstituteMessageBoard extends AppCompatActivity {

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_institute_message_board);

        insTool = (Toolbar) findViewById(R.id.institute_toolbar);
        setSupportActionBar(insTool);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setTitle("Institute Notice");

        listView = (ListView) findViewById(R.id.listView);
        dRef = FirebaseDatabase.getInstance().getReference();

        adapter  = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, list);
        listView.setAdapter(adapter);

        DatabaseReference classPostRef = dRef.child("admin").child("classPost");
        classPostRef.addChildEventListener(new ChildEventListener() {
            @Override
            public void onChildAdded(DataSnapshot dataSnapshot, String s) {

                    String post = dataSnapshot.child("post").getValue(String.class);
                    list.add(post);
                    adapter.notifyDataSetChanged();
    }

}

2 个解决方案

#1


0  

You are using default ArrayAdapter with simple_dropdown_item_1line this layout. It has single Textview with android:singleLine="true" cause of which data is showing in one line only.

您正在使用默认的ArrayAdapter和simple_dropdown_item_1line这种布局。它有单一的Textview与android:singleLine =“true”原因,其中数据仅显示在一行中。

Switch to custom ArrayAdapter and create row layout as per your requirement.

切换到自定义ArrayAdapter并根据您的要求创建行布局。

How to create custom array adapter?

如何创建自定义数组适配器?

#2


0  

Try,

android.R.layout.simple_list_item_1

instead of,

android.R.layout.simple_dropdown_item_1line

#1


0  

You are using default ArrayAdapter with simple_dropdown_item_1line this layout. It has single Textview with android:singleLine="true" cause of which data is showing in one line only.

您正在使用默认的ArrayAdapter和simple_dropdown_item_1line这种布局。它有单一的Textview与android:singleLine =“true”原因,其中数据仅显示在一行中。

Switch to custom ArrayAdapter and create row layout as per your requirement.

切换到自定义ArrayAdapter并根据您的要求创建行布局。

How to create custom array adapter?

如何创建自定义数组适配器?

#2


0  

Try,

android.R.layout.simple_list_item_1

instead of,

android.R.layout.simple_dropdown_item_1line