I am having a list view with many items. Each item has a number as its first character. I want for every entry of the list the number to be bold. I have a list array which I give to array adapter to make the list view. Values are not stable so I cannot put them in an xml
file. Is there any way to achieve my goal? I am making a "when my bus arrives" app
<?xml version="1.0" encoding="utf-8"?>
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<SearchView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/search_view"
android:queryHint="Αναζήτηση Γραμμής"
android:inputType="text">
</SearchView>
<ListView
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ListView
android:id="@+id/listview2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
<ListView
android:id="@+id/listview3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipeLayout"
android:visibility="gone"
android:paddingTop="8dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/listview4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
</android.support.v4.widget.SwipeRefreshLayout>
private void initUI() {
final ArrayList<String> arrayList = new ArrayList<>();
try {
AssetManager assetManager = getAssets();
ObjectInputStream input = new ObjectInputStream(new GZIPInputStream((assetManager.open("names.dat"))));
Object readObject = input.readObject();
input.close();
ArrayList<String> names = (ArrayList<String>) readObject;
arrayList.addAll(names);
routes = read_files("routes.dat");
line_route = read_files("line_route.dat");
lastcall= new ArrayList<String>();
editsearch= (SearchView) findViewById(R.id.search_view);
editsearch.setOnQueryTextListener(this);
swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeLayout);
swipeRefreshLayout.setOnRefreshListener(this);
Runnable refresh = new Runnable() {
public void run() {
if ((MainActivity.this.afikseis.getVisibility()==View.VISIBLE)&& !(swipeRefreshLayout.isRefreshing())){
get_time(lastcall.get(0),lastcall.get(1),lastcall.get(2));
}
}
};
ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
executor.scheduleAtFixedRate(refresh, 10, 30, TimeUnit.SECONDS);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
arrayAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, arrayList);
listView.setAdapter(arrayAdapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
print_routes(arrayList.get(i), line_route, routes);
print_routes(arrayAdapter.getItem(i).toString(), line_route, routes);
}
});
}
Thanks in advance