I have some result of array-list after I display the value through looping like this
{First=00157300-SPT R.ALONSO (M) D.GREEN, Fourth=360010.0, Second=10, Third=360000}
And I got that result from :
for(int i = 0; i<list.size(); i++){
Log.d("List Result :", String.valueOf(list.get(i)));
}
I create that arraylist from :
HashMap temp = new HashMap();
temp.put(FIRST_COLUMN, valueSpinner);
temp.put(SECOND_COLUMN, count);
temp.put(THIRD_COLUMN, price);
temp.put(FOURTH_COLUMN, total);
list.add(temp);
I create FIRST_COLUMN, SECOND_COLUMN,THIRD_COLUMN and FOURTH_COLUMN from Constant.java :
public class Constant {
public static final String FIRST_COLUMN = "First";
public static final String SECOND_COLUMN = "Second";
public static final String THIRD_COLUMN = "Third";
public static final String FOURTH_COLUMN = "Fourth";
}
And I use import to MainActivity.java :
import static com.testing.informationsystem.Constant.FIRST_COLUMN;
import static com.testing.informationsystem.Constant.SECOND_COLUMN;
import static com.testing.informationsystem.Constant.THIRD_COLUMN;
import static com.testing.informationsystem.Constant.FOURTH_COLUMN;
How can I get just the 00157300-SPT R.ALONSO (M) D.GREEN and 360010.0 ?
Thank you.
Well it seems as though you're adding a Map to the list, so you end up printing the Map's toString method. There probably isn't any need to have the Map in a list like that but I'll assume it should be. What you want to do is request the key-value pairs from the map instead of working with the toString method.
for(int i = 0; i < list.size(); i++)
{
HashMap temp = list.get(i);
Log.d("List Result :", "index " + i);
Log.d("List Result :", "First = " + temp.get(FIRST_COLUMN));
Log.d("List Result :", "Second = " + temp.get(SECOND_COLUMN));
Log.d("List Result :", "Third= " + temp.get(THIRD_COLUMN));
Log.d("List Result :", "Forth= " + temp.get(FOURTH_COLUMN));
}
Related
I am trying to add multiple values to an array, but it returns a cannot resolve error. Is there any way or work-around here?
for (Map.Entry<String,String> entry : hash.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
if(typePHP.equals("TARGET")) {
message += key + " " + value + "t\n";
}else {
message += key + " " + value + "r\n";
}
array.add(Integer.parseInt(key),value,typePHP,gamePHP);
//Heres the error.
}
Here's the error:Cannot resolve method 'add(int, java.lang.String, java.lang.String, java.lang.String)'
I need the single element to store 4 values at once and have an output like {109,40, TYPE, GAME};
First, ensure that your ArrayList is currently storing an object with a constructor of (String a, String b, String c). When you call array.add(new Item(a, b, c), Java needs to match that to an existing method.
public class Item {
public Item(String a, String b, String c) {
// initialize your object's variables here in the constructor
}
}
Then, you have to use new when you're creating a new object using add().
array.add(new Item(a, b, c));
See this from Java: Adding new objects to an ArrayList using a constructor
And this reference from Oracle about constructors: https://docs.oracle.com/javase/tutorial/java/javaOO/constructors.html
use addAll in this way:
array.addAll(Arrays.asList( key,value,typePHP,gamePHP) );
UPDATE:
You need a 2d array, based on this sentence I need the single element to store 4 values at once and have an output like {109,40, TYPE, GAME};
So, try this:
ArrayList<ArrayList<String>> array2d = new ArrayList<>();
array2d.add(new ArrayList<String>() {{
add("109");
add("40");
add("TYPE");
add("GAME");
}});
In your case, there should be something like this:
ArrayList<ArrayList<String>> array2d = new ArrayList<>();
for (Map.Entry<String,String> entry : hash.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
if(typePHP.equals("TARGET")) {
message += key + " " + value + "t\n";
}else {
message += key + " " + value + "r\n";
}
array2d.add(new ArrayList<String>() {{
add(key);
add(value);
add(typePHP);
add(gamePHP);
}});
}
You can create Custom object of your choice member
public class Item {
private int key;
private String value;
private String typePHP;
private String gamePHP;
public Item(int key, String value, String typePHP, String gamePHP) {
this.key = key;
this.value = value;
this.typePHP = typePHP;
this.gamePHP = gamePHP;
}
public int getKey() {
return key;
}
public void setKey(int key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getTypePHP() {
return typePHP;
}
public void setTypePHP(String typePHP) {
this.typePHP = typePHP;
}
public String getGamePHP() {
return gamePHP;
}
public void setGamePHP(String gamePHP) {
this.gamePHP = gamePHP;
}
}
Now you can use like
ArrayList<Item> itemArray = new ArrayList <>();
for (Map.Entry<String,String> entry : hash.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
if(typePHP.equals("TARGET")) {
message += key + " " + value + "t\n";
}else {
message += key + " " + value + "r\n";
}
itemArray.add(new Item(Integer.parseInt(key),value,typePHP,gamePHP));
}
I am using this method to call my service in my application.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.next);
String url = "url";
AQuery mAQuery = new AQuery(Next.this);
mAQuery.ajax(url, String.class, new AjaxCallback<String>() {
#Override
public void callback(String url, String data, AjaxStatus status) {
super.callback(url, data, status);
if (BuildConfig.DEBUG) {
Log.d("###$Request URL", url + "");
Log.d("###$Response ", data + "");
Log.d("###$Status Message : ", status.getMessage() + "");
Log.d("###$Status Code : ", status.getCode() + "");
}
if (null != data && status.getCode() != -101) {
String StringData = "" + data;
try {
JSONObject json = new JSONObject(StringData);
String COMP_REQ_ID = json.getString("COMP_REQ_ID");
String CompanyName = json.getString("CompanyName");
String COMP_REQ_TYPE = json.getString("COMP_REQ_TYPE");
String Name = json.getString("Name ");
myAwesomeTextview.setText("COMP_REQ_ID: " + COMP_REQ_ID + "\n" + "CompanyName:" + CompanyName + "\n" + "COMP_REQ_TYPE: " + COMP_REQ_TYPE + "\n" + "Name : " + Name);
} catch (JSONException e) {
myAwesomeTextview.setText("" + e);
}
But the data coming from server is not getting display on my phone screen.
The data i got from my service is given below:
[{"Name":null,"PositionName":null,"DateOfEvent":null,"EvetnId":0,"HetId":0,"EventDate":null,"COMP_REQ_ID":9714,"COMP_REQ_TYPE":"Intership","JobTitle":"Administrator","CompanyName":"Jensor's International (Ltd).","ReqQualification":"","DegreeName":"B.E/B.Tech,M.C.A,M.B.A,B.A,B.A.M.S,B.Com,B.S.W","Post_Status":1,"Eventdate":"21/06/2016","JobsOrInternships":null},{"Name":null,"PositionName":null,"DateOfEvent":null,"EvetnId":0,"HetId":0,"EventDate":null,"COMP_REQ_ID":9713,"COMP_REQ_TYPE":"Intership","JobTitle":"junior counselor","CompanyName":"Jensor's International (Ltd).","ReqQualification":"","DegreeName":"B.E/B.Tech,M.C.A,M.B.A,B.B.M,B.Com,B.F.A","Post_Status":1,"Eventdate":"21/06/2016","JobsOrInternships":null}
How to display it.
You should use JSONArray to parse your result
JSONArray rootArray = new JSONArray(jsonString);
int len = rootArray.length();
for(int i = 0; i < len; ++i) {
JSONObject json = rootArray.getJSONObject(i);
String COMP_REQ_ID = json.getString("COMP_REQ_ID");
}
Or you can use GSon library to parse the result for you. I recommend this post as example how to query data from ASP.NET Web API.
I think you should make your question clear because I'm not sure if you have problem with getting data or showing data to ui.
public class ArrayBean {
public String Name;
public String PositionName;
public String DateOfEvent;
public String EvetnId;
public String HetId;
public String EventDate;
public String COMP_REQ_ID;
public String COMP_REQ_TYPE;
public String JobTitle;
public String CompanyName;
public String ReqQualification;
public String DegreeName;
public String Eventdate;
public String JobsOrInternships;
}
ArrayBean bean;
JSONArray array=new JSONArray("StringData ");
JSONObject json;
for(int i=0;i<array.length();i++){
bean=new ArrayBean();
json=new JSONObject();
json=array.getJSONObject(i);
bean.COMP_REQ_ID=json.getString("COMP_REQ_ID");
bean.COMP_REQ_TYPE=json.getString("COMP_REQ_TYPE");
bean.CompanyName=json.getString("CompanyName");
bean.DateOfEvent=json.getString("DateOfEvent");
bean.EventDate=json.getString("EventDate");
bean.EvetnId=json.getString("EvetnId");
bean.HetId=json.getString("HetId");
bean.JobsOrInternships=json.getString("JobsOrInternships");
bean.JobTitle=json.getString("JobTitle");
bean.Name=json.getString("Name");
bean.PositionName=json.getString("PositionName");
bean.ReqQualification=json.getString("ReqQualification");
}
Note, care about data-types in JSON e.g key COMP_REQ_ID has value data-type is int. You should use optString or optInt instead of getString or getInt to parse your result
JSONArray rootArray = new JSONArray(jsonString);
int len = rootArray.length();
for(int i = 0; i < len; ++i) {
JSONObject json = rootArray.optJSONObject(i);
int COMP_REQ_ID = json.optInt("COMP_REQ_ID");
String COMP_REQ_TYPE = json.optString("COMP_REQ_TYPE");
...
}
i used this code
JSONArray rootArray = new JSONArray(StringData);
int len = rootArray.length();
for (int i = 0; i < len; ++i) {
JSONObject json = rootArray.optJSONObject(i);
int COMP_REQ_ID = json.optInt("COMP_REQ_ID");
String COMP_REQ_TYPE = json.optString("COMP_REQ_TYPE");
String CompanyName = json.getString("CompanyName ");
String Name = json.getString("Name");
String PositionName = json.getString("PositionName");
myAwesomeTextview.setText("COMP_REQ_ID:" + COMP_REQ_ID + "\n" + "COMP_REQ_TYPE" + COMP_REQ_TYPE + "\n" + "CompanyName" + CompanyName + "\n" + "Name" + Name + "\n" + "PostionNmae" + PositionName);
}
But then also the result is not diplayed on my phone And in android studio logcat it showing me this:
reporting:java.lang.NullPointerException at com.example.anand.Next$1.callback(Next.java:55)
at com.example.anand.Next$1.callback(Next.java:24)
at
I have trouble with a JSON array, and I really hope there is someone who can help me.
Lets say I have a class with JSON data and I'm sending "intent putextra" to another activity.
How can I change the value of null before I send it to another activity? I did a few prints to discover the null values and they are different, example :
Monday : null
Tuesday : 08:30 - 18:00
Wednesday : 09:00 - 17:00
**and so on.**
The problem is that --> I have all json data and I parsing them into objects, but I would like to before "intent.putextra" and send them to another activity finds null and replace them with "Closed"
so it will look like
Monday : Closed
Tuesday : 08:30 - 18:00
Wednesday : 09:00 - 17:00
EDIT
public class LocationBased extends ListActivity{
// JSON Node names
private static final String TAG_Location = "location_id";
private static final String TAG_Company = "company_id";
private static final String TAG_NAME = "name";
private static final String TAG_ADDRESS = "address";
private static final String TAG_PLACE = "place";
private static final String TAG_POSTAL = "postal";
private static final String TAG_CITY = "city";
private static final String TAG_MONDAY = "monday";
private static final String TAG_TUESDAY = "tuesday";
private static final String TAG_WEDNESDAY = "wednesday";
private static final String TAG_THURSDAY = "thursday";
private static final String TAG_FRIDAY = "friday";
private static final String TAG_SATURDAY = "saturday";
private static final String TAG_SUNDAY = "sunday";
private static final String TAG_TYPE = "type";
private static final String TAG_LAT = "lat";
private static final String TAG_LNG = "lng";
private static final String TAG_NOCAR = "nocar";
private static final String TAG = "Debug of Project"; //
private String a;
private String b;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
SQLiteDatabase db = openOrCreateDatabase("mydb.db", Context.MODE_PRIVATE, null);
db.execSQL("CREATE TABLE IF NOT EXISTS gps_kordinater (ID INTEGER PRIMARY KEY AUTOINCREMENT, Latitude REAL, Longitude REAL);");
String query = "SELECT Latitude,Longitude FROM gps_kordinater WHERE Id = (SELECT MAX(Id) FROM gps_kordinater)";
Cursor cursor = db.rawQuery(query, null);
if(cursor != null)
{
cursor.moveToFirst();
a = cursor.getString(0);
b = cursor.getString(1);
}
String url = "http://webservice.XXX.XX/webservice/getLocationList.php?lat="+ a +"&lng="+ b +"";
Log.d(TAG, "Leyth URL = Lat : " + a +" Long : " + b);
// now enabled if disabled = ingen support for jb aka 4.0
if (android.os.Build.VERSION.SDK_INT > 9) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
}
ArrayList<HashMap<String, String>> contactList = new ArrayList<HashMap<String, String>>();
JSONParser jParser = new JSONParser();
JSONArray json = jParser.getJSONFromUrl(url);
try {
for(int i = 0; i < json.length(); i++){
JSONObject c = json.getJSONObject(i);
String location_id = c.getString(TAG_Location);
String company_id = c.getString(TAG_Company);
String name = c.getString(TAG_NAME);
String address = c.getString(TAG_ADDRESS);
String place = c.getString(TAG_PLACE);
String postal = c.getString(TAG_POSTAL);
String city = c.getString(TAG_CITY);
String monday = c.getString(TAG_MONDAY);
String tuesday = c.getString(TAG_TUESDAY);
String wednesday = c.getString(TAG_WEDNESDAY);
String thursday = c.getString(TAG_THURSDAY);
String friday = c.getString(TAG_FRIDAY);
String saturday = c.getString(TAG_SATURDAY);
String sunday = c.getString(TAG_SUNDAY);
String type = c.getString(TAG_TYPE);
String lat = c.getString(TAG_LAT);
String lng = c.getString(TAG_LNG);
String nocar = c.getString(TAG_NOCAR);
// creating new HashMap
HashMap<String, String> map = new HashMap<String, String>();
// adding each child node to HashMap key => value
map.put(TAG_Location, location_id);
map.put(TAG_Company, company_id);
map.put(TAG_NAME, name);
map.put(TAG_ADDRESS, address);
map.put(TAG_PLACE, place);
map.put(TAG_POSTAL, postal);
map.put(TAG_CITY, city);
map.put(TAG_MONDAY, monday);
map.put(TAG_TUESDAY, tuesday);
map.put(TAG_WEDNESDAY, wednesday);
map.put(TAG_THURSDAY, thursday);
map.put(TAG_FRIDAY, friday);
map.put(TAG_SATURDAY, saturday);
map.put(TAG_SUNDAY, sunday);
map.put(TAG_TYPE, type);
map.put(TAG_LAT, lat);
map.put(TAG_LNG, lng);
map.put(TAG_NOCAR, nocar);
// Log.d(TAG, "Leyth Days = Mandag : " + monday +" Onsdag : " + wednesday);
// adding HashList to ArrayList
contactList.add(map);
}
} catch (JSONException e) {
e.printStackTrace();
Log.e("JSON Parser", "Error parsing data " + e.toString());
}
/**
* Updating parsed JSON data into ListView
* */
ListAdapter adapter = new SimpleAdapter(this, contactList,
R.layout.list_item,
new String[] { TAG_LAT, TAG_LNG, TAG_POSTAL }, new int[] {
R.id.name, R.id.email, R.id.mobile });
setListAdapter(adapter);
// selecting single ListView item
ListView lv = getListView();
// Launching new screen on Selecting Single ListItem
lv.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// getting values from selected ListItem
String name = ((TextView) view.findViewById(R.id.name)).getText().toString();
String cost = ((TextView) view.findViewById(R.id.email)).getText().toString();
String description = ((TextView) view.findViewById(R.id.mobile)).getText().toString();
String mandag = ((TextView) view.findViewById(R.id.mandag)).getText().toString();
String tirsdag = ((TextView) view.findViewById(R.id.tirsdag)).getText().toString();
String onsdag = ((TextView) view.findViewById(R.id.onsdag)).getText().toString();
String torsdag = ((TextView) view.findViewById(R.id.torsdag)).getText().toString();
String fredag = ((TextView) view.findViewById(R.id.fredag)).getText().toString();
String lordag = ((TextView) view.findViewById(R.id.lordag)).getText().toString();
String sondag = ((TextView) view.findViewById(R.id.sondag)).getText().toString();
// Starting new intent
Intent in = new Intent(getApplicationContext(), dk.mitaffald.maps.MainActivity.class);
in.putExtra(TAG_LAT, name);
in.putExtra(TAG_LNG, cost);
in.putExtra(TAG_Company, description);
in.putExtra(TAG_MONDAY, mandag);
in.putExtra(TAG_TUESDAY, tirsdag);
in.putExtra(TAG_WEDNESDAY, onsdag);
in.putExtra(TAG_THURSDAY, torsdag);
in.putExtra(TAG_FRIDAY, fredag);
in.putExtra(TAG_SATURDAY, lordag);
in.putExtra(TAG_SUNDAY, sondag);
startActivity(in);
}
});
}
}
I am also suffering for this problem in past but i do not know this is good solution but it works for me. Hope it is usefull to you also.
String jsonObject_string ;
try {
if (jsonObject != null) {
// ur stuff when not null
}
} catch (Exception e) {
// TODO: handle exception
// when null it automatic fill value
jsonObject_string = "Closed";
}
As I understand you want to replace any null string with a specific string , say "Closed".
This doesn't have anything todo with JSON, if this were my code I would do a simple check before adding those values to my intent. the code will look something like this:
Intent in = new Intent(getApplicationContext(), dk.mitaffald.maps.MainActivity.class);
in.putExtra(TAG_LAT, name == null ? "Closed" : name);
in.putExtra(TAG_LAT, cost== null ? "Closed" : cost);
in.putExtra(TAG_Company, description == null ? "Closed" : description );
in.putExtra(TAG_MONDAY, mandag == null ? "Closed" : mandag);
....
And so on.
name == null ? "Closed" : name ;
Simple asks if name is null then the value is closed, else return name.
it is the same as :
if (name == null){
in.putExtra(TAG_LAT, "Closed");
} else {
in.putExtra(TAG_LAT, name);
}
I hope that is what you're looking for
Why not try to replace all null strings in the JSON as a string before you parse the JSON file/object?
Possible other solution could be looping through every object checking if they're null. then replacing that for Closed
EDIT:
Load the JSON object as a string and then replace all null to Closed like this:
String JSON = JsonObject.toString();
JSON.replace("null", "Closed");
EDIT 2:
add this below JSONArray json = jParser.getJSONFromUrl(url);:
String s = json.toString(); // converts json object to string
json.replace("null", "Closed"); // replaces null for Closed
JSONArray json = new JSONArray(s); // converts back to json object
if(c.getString(TAG_MONDAY!=null && c.getString(TAG_MONDAY).length>0 && !(c.getString(TAG_MONDAY).equals("")))
{
String monday=c.getString(TAG_MONDAY);
}
else
{
String monday="Closed";
}
I want to compare the value of the id in sqlite to the value of TAG_ID coming from the json webservice.I just stuck up to do this..
What I have tried so far is
class LoadAll extends AsyncTask<String, String, String>
{
protected String doInBackground(String... args)
{
Log.i("url ",url_all_products);
List<NameValuePair> params = new ArrayList<NameValuePair>();
JSONObject json = jParser.makeHttpRequest(url_all_products, "GET",params);
Log.w("All book: ", json.toString());
Log.i(url_all_products, url_all_products);
try
{
System.err.println("json array "+json.getJSONArray(TAG_PRODUCTS));
bookProduct = json.getJSONArray(TAG_PRODUCTS);
}
catch (JSONException e)
{
e.printStackTrace();
}
if(data_exist!=bookProduct.length()){
Log.i("in update","m here");
Cursor cursors = getRawEvents("select id from bcuk_book");
try{
for (int i = 0; i < bookProduct.length(); i++) {
JSONObject c = bookProduct.getJSONObject(i);
String Bid = c.getString(TAG_ID);
ArrayList<String> mapId = new ArrayList<String>();
mapId.add(TAG_ID);
Log.e(Bid,Bid);
while(cursors.moveToNext())
{
System.err.println("update coded STEON"+cursors.getString(0));
Log.e(Bid,c.getString(TAG_ID));
}
}
}
catch(JSONException e){
e.printStackTrace();
}
}
else{
Log.i("Done good","m here");
}
return null;
}
The reason behind
if(data_exist!=bookProduct.length()){
this statement is the variable data_exist=cursor.getCount();
and the bookProduct.length is the length of the jsonarray I want to compare them if the length is not same then I want to update the new values into the sqlite.could any one suggest me the approach to do this
if the length is not same then I want to update the new values into
the sqlite.
Not a good way to update databases.
Suppose that there is some changes in the server database fields. Same count but the contents is different.
This is the way I do:
String sql = "select * from " + DB_TABLE + " where " + TAG_ID + "='" + id + "'";
Cursor c = database.rawQuery(sql, null);
c.moveToFirst();
if( c.getCount() > 0){ // already in the database
// update entry with TAG_ID = id
}
else{ // new entry
// add new entry
}
I have a HashMap
HashMap<String, Integer> map = new HashMap<String, Integer>();
in the map there are some value. I want to get the value one by one and add it in listview. The value which is in map are
{Intent { cmp=Bluetooth/300 }=300, Intent { cmp=Audio/400 }=400,
Intent { cmp=Video/500 }=500, Intent { cmp=Display/100 }=100, Intent {
cmp=WiFi/200 }=200}
There are two textview in the listview.
And I want to be display in listview as
Display 100
WiFi 200
Bluetooth 300.
Now I public my Adapter Class which will be helpful to you...
private class NewAdapter extends BaseAdapter {
public NewAdapter(IntentTestingActivity intentTestingActivity,
HashMap<String, Integer> map) {
}
#Override
public int getCount() {
Log.d(TAG, "Map size is: " + map.size());
return map.size();
}
#Override
public Object getItem(int arg0) {
return null;
}
#Override
public long getItemId(int arg0) {
return 0;
}
#Override
public View getView(int position, View view, ViewGroup parent) {
View v = view;
if (v == null) {
LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.class_name, null);
}
TextView className = (TextView) v.findViewById(R.id.name);
TextView tagName = (TextView) v.findViewById(R.id.tag_name);
Integer key_name;
key_name = map.get(name);
Log.d(TAG, "Complete map is: " + map.toString());
// String tag = map.get(tagName).toString();
// Integer name = map.get(className);
String keyName;
keyName = map.toString();
Log.d(TAG, "KeyName is: " + map.get(tag));
for (int i = 0; i < map.size(); ++i)
Log.d(TAG, "Tag is: " + tag + " and Name is: " + name + " and Intent is: "+intent);
HashMap<String, Integer> hashmap = map;
for (Entry<String, Integer> e : hashmap.entrySet()) {
String key = e.getKey();
int value = e.getValue();
Set<String>keyname = map.keySet();
Log.d(TAG, "Key: " + key+ " Value: "+value);
}
className.setText(name.toString());
// tagName.setText(keyName);
return v;
}
}
Where name is a just String in which holding all keyValue, such as Display, Vedio ect.
Thanx in advance...
You can create a POJO class with getter-setter and set the key and value to that class.
List<POJO> list = new ArrayList<POJO>();
Iterator<Entry<String, Integer>> iterator = map.entrySet().iterator();
Entry< String, Integer> entry;
while(iterator.hasNext()){
POJO obj = new POJO();
entry = iterator.next();
Log.d("Key Value",entry.getKey()+" "+entry.getValue());
obj.setKey(entry.getKey());
obj.setValue(entry.getValue());
list.add(obj);
}
And then set this list to your Adapter class. This is will be an easy way.
Build a custom Adapter that uses your HashMap and...
Whenever you want to do processing with the views in a ListView you
need to create a custom adapter that will handle your logic
implementation and pass that information to the views as necessary.
Seems like you are showing both values together as a single string, so you may achieve this by simply doing in this way:
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.id.text1);
for(String key : map.keySet()){
adapter.add(key + " " + map.get(key));
}
yourListView.setAdapter(adapter);