textview xml연결오류
조회수 771회
자바코드
package com.example.myapplication;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.google.firebase.database.DataSnapshot; import com.google.firebase.database.DatabaseError; import com.google.firebase.database.DatabaseReference; import com.google.firebase.database.FirebaseDatabase; import com.google.firebase.database.ValueEventListener;
import java.text.CollationElementIterator;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference myRef = database.getReference();
myRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
// This method is called once with the initial value and again
// whenever data at this location is updated.
Object value = dataSnapshot.getValue(Object.class);
textview1.setText.value.toString();
}
@Override
public void onCancelled(DatabaseError error) {
// Failed to read value
}
});
}
}
xml코드
<TextView
android:id="@+id/textview1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="test" />
인데 textview1.setText.value.toString(); 코드에서 오류가 납니다 리소스 연결에 오류가 있는 건가요?ㅠㅠ
댓글 입력