【发布时间】:2017-10-03 01:23:51
【问题描述】:
我有一个可以正常工作的editText 和一个列表视图。但我想让列表视图在用户开始输入之前不可见。 我查看了这些链接,但没有用
Show/Hide the Custom ListView in android
Hiding Listview until search is initiated
Hide an android ListView until search string is entered
这是我的代码
public class MapAcWithMarker extends FragmentActivity implements OnMapReadyCallback {
public ListView listView;
private View parentView;
public DataAdapter adapter;
ArrayList<Locations> arrayListTemp=new ArrayList<>();
EditText inputSearch;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_recyc);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
inputSearch = (EditText) findViewById(R.id.inputSearch);
listView = (ListView) findViewById(R.id.listView);
inputSearch.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {
}
}
@Override
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
int arg3) {
if(listView.getVisibility() != View.INVISIBLE)
listView.setVisibility(View.INVISIBLE);
}
@Override
public void afterTextChanged(Editable arg0) {
if(listView.getVisibility() != listView.VISIBLE)
listView.setVisibility(listView.VISIBLE);
}
});
【问题讨论】:
标签: android listview search android-edittext