I want to achieve something you can see in the Android BlueTooth settings: two listviews and one activity. First listview contains already paired devices, second - newly discovered (this one doesn't have fixed size). How can I develop activity like this? Putting listviews in scrollview isn't very good idea as far as I know. So, what would you recommend?
Asked
Active
Viewed 112 times
2 Answers
1
I think you do not need two ListViews at all. You need to implement one ListView with headers as described here.
public class MainActivity extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
List<Item> items = new ArrayList<Item>();
items.add(new Header("Header 1"));
items.add(new ListItem("Text 1", "Rabble rabble"));
items.add(new ListItem("Text 2", "Rabble rabble"));
items.add(new ListItem("Text 3", "Rabble rabble"));
items.add(new ListItem("Text 4", "Rabble rabble"));
items.add(new Header("Header 2"));
items.add(new ListItem("Text 5", "Rabble rabble"));
items.add(new ListItem("Text 6", "Rabble rabble"));
items.add(new ListItem("Text 7", "Rabble rabble"));
items.add(new ListItem("Text 8", "Rabble rabble"));
TwoTextArrayAdapter adapter = new TwoTextArrayAdapter(this, items);
setListAdapter(adapter);
}
}

DimDim
- 371
- 1
- 18
0
Why don't you just put the two ListViews in LinearLayout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2">
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/listview1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/listview2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
</LinearLayout>

DimDim
- 371
- 1
- 18
-
That's some kind of interesting this two columns, but I wanted to make it as similar to android settings as possible. Nevertheless I'll make as you advise if I'm not able to figure out the other way of doing it. Thanks ;) – meDarq Mar 17 '18 at 22:42
-
Provide some pictures how you want looks like – DimDim Mar 17 '18 at 22:46
-
 Second ListView is empty because no BT device is around – meDarq Mar 17 '18 at 23:00