我想在TextView中显示结果,将Firebase中存储的数据与EditText中输入的值进行比较。 模拟器无法关闭,但是代码不起作用。
我该怎么办?
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
searchbtn = (Button)findViewById(R.id.searchbtn);
searchurl = (EditText)findViewById(R.id.search_url);
showurl = (TextView)findViewById(R.id.showresult);
searchbtn.setOnClickListener(new View.OnClickListener() {
String get_url = searchurl.getText().toString();
@Override
public void onClick(View view) {
dbref = db.getReference("url");
dbref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot messageData : dataSnapshot.getChildren()) {
Post post = dataSnapshot.getValue(Post.class);
if (get_url==post.geturlin()){
showurl.setText("Warning");
}
else {
showurl.setText("OKAY");
}
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
});
}