• 10
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

I have weather app, which is get weather information json from here:

http://icomms.ru/inf/meteo.php/?tid=44

There's a minus in "temp" value (for ex. : "temp":"?16"), and when I get value from json with retrofit2 and show it in textview it shows −16 instead of -16

Screenshot

How I can show -16 instead of −16?

Fragment from RecyclerViewAdapter (I use it to show weather info for multiply days), where I set text to textview

@Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        Meteo meteo = data.get(position);
        holder.date.setText(meteo.date);
        holder.tod.setText(meteo.tod);
        holder.pressure.setText(meteo.pressure);

        // THIS IS TEMPERATURE SETTING TEXT LINE
        holder.temp.setText(meteo.temp);

        holder.humidity.setText(meteo.humidity);
        holder.wind.setText(meteo.wind);
        holder.cloud.setText(meteo.cloud);
}

Weather data class:

public class Meteo {
    public String date;
    public String tod;
    public String pressure;
    public String temp;
    public String humidity;
    public String wind;
    public String cloud;
}

Response body:

    Retrofit retrofit = new Retrofit.Builder()
            .baseUrl(APIService.HOST)
            .addConverterFactory(GsonConverterFactory
                    .create())
            .build();

    APIService apiService = retrofit.create(APIService.class);

    Call<List<Meteo>> call = apiService.getMeteo(44);

    call.enqueue(new Callback<List<Meteo>>() {
        @Override
        public void onResponse(Call<List<Meteo>> call, Response<List<Meteo>> response) {
            MeteoAdapter adapter = new MeteoAdapter(response.body());
            // Method show just shows list of weather data
            getViewState().show(adapter);
        }

        @Override
        public void onFailure(Call<List<Meteo>> call, Throwable t) {
            Log.d("MyLog", "WRONG");
        }
    });

Try this. I use it for formatting html tags in a textview:

String s = Html.fromHtml("&minus;16");
tv.setText(s);

Reasoning: It sets the text as a Spanned object, rather than a string.

Note: Cannot test this currently, sorry if it doesnt work.

  • 1
Reply Report