在我的程序中,我有两个AutoCompleteTextView
aButton
和 aTableLayout
来显示某个结果。在这个程序中TableLayout
是隐藏的,只有在结果生成后才会出现。
我还希望Button
仅在用户填写后才出现,AutoCompleteTextView
但在我编写的代码中,它没有按照我想要的方式运行。
calculate = (Button)findViewById(R.id.calculate);
if(location.getText().toString().length()<1 && destination.getText().toString().length()<1)
{
calculate.setVisibility(View.INVISIBLE);
}
else
{
calculate.setVisibility(View.VISIBLE);
calculate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(location.getText().toString().length()<1 || destination.getText().toString().length()<1)
{
Toast.makeText(getApplicationContext(), "Give values before placing a query", Toast.LENGTH_LONG).show();
}
else{
@SuppressWarnings("deprecation")
String url = "http://maps.googleapis.com/maps/api/distancematrix/json?origins="+URLEncoder.encode(location.getText().toString())+"&destinations="+URLEncoder.encode(destination.getText().toString())+"&unit=metric&mode=driving&sensor=false";
new ReadDistanceJSONFeedTask().execute(url);
z=+1;
isNormal=false;
supportInvalidateOptionsMenu();
}
}
});
}
在这段代码中Button
根本没有出现。有人可以帮忙吗?提前致谢。