尝试做一些有点棘手的事情,在那里我为回显的给定关键字设置颜色,这是从网页抓取中收集的。我得到了一次答案,但无法让它真正改变任何颜色。这是我正在使用的代码。
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_galery, container, false);
String url = "http://bls.hol.es/read.php";
lvhape = (RecyclerView) getView().findViewById(R.id.lvhape);
LinearLayoutManager llm = new LinearLayoutManager(gallary.getContext());
llm.setOrientation(LinearLayoutManager.VERTICAL);
lvhape.setLayoutManager(llm);
requestQueue = Volley.newRequestQueue(galery.this);
list_data = new ArrayList<HashMap<String, String>>();
stringRequest = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.d("response", response);
try {
JSONObject jsonObject = new JSONObject(response);
JSONArray jsonArray = jsonObject.getJSONArray("result");
for (int a = 0; a < jsonArray.length(); a++) {
JSONObject json = jsonArray.getJSONObject(a);
HashMap<String, String> map = new HashMap<String, String>();
map.put("id", json.getString("id"));
map.put("nama", json.getString("nama"));
map.put("alamat", json.getString("alamat"));
map.put("poto", json.getString("poto"));
list_data.add(map);
AdapterList adapter = new AdapterList(galery.this, list_data);
lvhape.setAdapter(adapter);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getActivity().getApplicationContext(), error.getMessage(), Toast.LENGTH_SHORT).show();
}
});
requestQueue.add(stringRequest);
return rootView;
}
正在吐出这一结果:道琼斯指数21271.97 + 89.44(0.42%)纳斯达克6207.92 -113.85(-1.80%)标准普尔500指数2431.77 -2.02(-0.08%)
我怎么能将它格式化为始终为ex,DJIA的单词着色为红色?我理解将要发生的事情的逻辑,但不知道如何使其与现有代码一起使用。
我曾经提供过这个答案,但实际上并没有改变“DJIA”的颜色。也许那里有人知道我做错了什么? *记住这是我在这里处理的文字。
"$$('tbody')[0].parentNode.removeChild($$('tbody')[0]);
感谢您的任何反馈!!
答案 0 :(得分:1)
<label class="control-label" for="nama_hukuman">Area</label>
<div class="controls">
<select data-placeholder="Regional Area.." class="chzn-select" style="width:300px;" tabindex="2" name="area" id="area">
<option value=""></option>
<option value="SUMBAGSEL" <?php if($area == 'SUMBAGSEL'){echo "selected";} ?> >SUMBAGSEL</option>
<option value="KALIMANTAN" <?php if($area == 'KALIMANTAN'){echo "selected";} ?> >KALIMANTAN</option>
<option value="BALINUSRA" <?php if($area == 'BALINUSRA'){echo "selected";} ?> >BALINUSRA</option>
<option value="SULAWESI" <?php if($area == 'SULAWESI'){echo "selected";} ?> >SULAWESI</option>
<option value="MALIRJA" <?php if($area == 'MALIRJA'){echo "selected";} ?> >MALIRJA</option>
</select>
</div>
<label class="control-label" for="nama_hukuman">Cluster</label>
<div class="controls">
<select data-placeholder="Cluster Area.." class="chzn-select" style="width:300px;" tabindex="2" name="cluster" id="cluster">
<option value=""></option>
<option value="Kalimantan Timur" data-chained="KALIMANTAN">Kalimantan Timur</option>
<option value="Bali" data-chained="BALINUSRA">Bali</option>
<option value="Lombok" data-chained="BALINUSRA">Lombok</option>
</select>
</div>
?