如何使用openweathermap在android菜单中的°C /°F之间进行更改

menu.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/degrees"
android:title="Celsius / Fahrenheit"
app:showAsAction="never"/>
</menu>MainActivity.java
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu, menu);
return true;
}
@Override
public boolean onContextItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.menu.menu:
// How do change between Celsius and Fahrenheit
break;
}
return true;
}
}Dropbox链接,以获得更深的视图(如果需要)
发布于 2018-11-16 01:11:54
单位格式
描述:
有标准单位、公制单位和帝国单位。
参数:
单位公制,帝国。当不使用“单位”参数时,默认情况下格式为“标准”。
温度单位有华氏温度,摄氏单位和开尔文单位。 对于以华氏表示的温度使用units=imperial作为摄氏度使用units=metric温度在开尔文默认情况下,不需要在API调用中使用单位参数 所有API参数的列表,其单元为openathermap.org/ with
API调用的示例:
standard api.openweathermap.org/data/2.5/find?q=London
metric api.openweathermap.org/data/2.5/find?q=London&units=metric
imperial api.openweathermap.org/data/2.5/find?q=London&units=imperialhttps://stackoverflow.com/questions/53329917
复制相似问题