我正在尝试监视日志文件,然后显示特定请求调用的计数,输出将显示标题行,其中包含每个请求的名称“ PUT GET HEAD”,并在其下方显示每个节点的请求计数每行。 我需要刷新显示每1秒计数的变量的输出
以下代码的问题,脚本会继续删除前几行并转到屏幕顶部,而输出应该是固定的,只有请求数应该刷新
private List<String> spinnerItem;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mainBinding = DataBindingUtil.setContentView(this, R.layout.activity_main);
spinnerItem = new ArrayList<>();
setSpinner();
}
public void displayCities(List<CityResponse.City> cities) {
mainBinding.helloText.setText(cities.get(508).getNama());
for (CityResponse.City city : cities) {
Log.d(TAG, city.getNama());
spinnerItem.add(city.getNama());
}
}
private void setSpinner(){
ArrayAdapter<String> adapter = new ArrayAdapter<>(getApplicationContext(), android.R.layout.simple_spinner_item, spinnerItem);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mainBinding.spinnerCity.setAdapter(adapter);
mainBinding.spinnerCity.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String citySelected = parent.getItemAtPosition(position).toString();
Toast.makeText(parent.getContext(), "City : " + citySelected, Toast.LENGTH_LONG).show();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
Toast.makeText(CityActivity.this, "Not Selected", Toast.LENGTH_LONG).show();
}
});
}
这是预期的输出:
节点PUT-HEAD-GET-删除 节点2 1849 2183 41387 0
#node-3 5339 8534 40838 0
#node-4 1829 2196 46503 0
#预期输出:每1秒刷新一次数字时,显示的内容应与上面相同
答案 0 :(得分:0)