Я хочу отобразить текст в моем окне просмотра, но он не появляется, только текст электронной почты отображается, а остальные нет. как заставить это появиться? это мой адаптер держателя вида
public TextView teksemail;
public TextView namanya;
public TextView golongannya;
ItemClickListener itemClickListener;
public listOnlineViewHolder(@NonNull View view) {
super(view);
teksemail = (TextView) view.findViewById(R.id.teksemail);
namanya = (TextView) view.findViewById(R.id.namanya);
golongannya = (TextView) view.findViewById(R.id.golongan);
view.setOnClickListener(this);
}
public void setItemClickListener(ItemClickListener itemClickListener) {
this.itemClickListener = itemClickListener;
}
@Override
public void onClick(View v) {
itemClickListener.onClick(v, getAdapterPosition());
}
это мой информационный класс
public class information {
public String email;
public String nama;
public String nalamat;
public String noTelpon;
public String golDar;
public String imageUrl;
public information() {
}
public information(String email, String nama, String nalamat, String noTelpon, String golDar, String imageUrl) {
this.email = email;
this.nama = nama;
this.nalamat = nalamat;
this.noTelpon = noTelpon;
this.golDar = golDar;
this.imageUrl = imageUrl;
}
public String getEmail() {
return email;
}
public String getNama() {
return nama;
}
public String getNalamat() {
return nalamat;
}
public String getNoTelpon() {
return noTelpon;
}
public String getGolDar() {
return golDar;
}
и это мой видоискатель кода в моей деятельности
private FusedLocationProviderClient fused;
public TextView goldar, nama, telpon, alamat;
DatabaseReference onlineRef, currentUserRef, counterRef, locationsDatabase,databaseReference;
FirebaseRecyclerAdapter<information, listOnlineViewHolder> firebaseRecyclerAdapter;
int waktu = 3000;
RecyclerView list;
RecyclerView.LayoutManager layoutManager;
private FirebaseUser firebaseUser;
private FirebaseAuth firebaseAuth;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list_online);
list = (RecyclerView) findViewById(R.id.listonline);
list.setHasFixedSize(true);
layoutManager = new LinearLayoutManager(this);
list.setLayoutManager(layoutManager);
nama = findViewById(R.id.teksnama);
alamat = findViewById(R.id.teksalamat);
telpon = findViewById(R.id.tekstelpon);
goldar = findViewById(R.id.teksgoldar);
firebaseAuth = FirebaseAuth.getInstance();
if (firebaseAuth.getCurrentUser() != null) {
fused = LocationServices.getFusedLocationProviderClient(this);
//databaseReference = FirebaseDatabase.getInstance().getReference().child(firebaseUser.getUid()).child("data");
locationsDatabase = FirebaseDatabase.getInstance().getReference("locations");
onlineRef = FirebaseDatabase.getInstance().getReference().child(".info/connected");
counterRef= FirebaseDatabase.getInstance().getReference("lastOnline");
currentUserRef = FirebaseDatabase.getInstance().getReference("lastOnline").
child(FirebaseAuth.getInstance().getCurrentUser().getUid());
databaseReference = FirebaseDatabase.getInstance().getReference(firebaseAuth.getCurrentUser().getUid()).child("data");
//load user info
databaseReference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
String namanya = dataSnapshot.child("nama").getValue(String.class);
String addnya = dataSnapshot.child("alamat").getValue(String.class);
String nonya = dataSnapshot.child("noTelpon").getValue(String.class);
String goldarnya = dataSnapshot.child("golDar").getValue(String.class);
nama.setText(namanya);
alamat.setText(addnya);
telpon.setText(nonya);
goldar.setText(goldarnya);
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
displayLocation();
if (ActivityCompat.checkSelfPermission(listOnline.this, Manifest.permission.ACCESS_COARSE_LOCATION)
!= PackageManager.PERMISSION_GRANTED && (ActivityCompat.checkSelfPermission
(listOnline.this, Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED)) {
ActivityCompat.requestPermissions(listOnline.this, new String[] {
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_FINE_LOCATION
},MY_PERMISSION_REQUEST_CODE);
} else {
if (checkPlayService()) {
buildGoogleApiClient();
createLocationRequest();
displayLocation();
}
}
}
}, waktu);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
setUpSystem();
//load all user from firebase
updateList();
}
}, waktu);
} else {
Toast.makeText(this, "Hai Resipienku!", Toast.LENGTH_SHORT).show();
if (ActivityCompat.checkSelfPermission(listOnline.this, Manifest.permission.ACCESS_COARSE_LOCATION)
!= PackageManager.PERMISSION_GRANTED && (ActivityCompat.checkSelfPermission
(listOnline.this, Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED)) {
ActivityCompat.requestPermissions(listOnline.this, new String[] {
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_FINE_LOCATION
},MY_PERMISSION_REQUEST_CODE);
fused.getLastLocation().addOnSuccessListener(new OnSuccessListener<Location>() {
@Override
public void onSuccess(Location location) {
Toast.makeText(listOnline.this, "get your location!", Toast.LENGTH_SHORT).show();
}
});
}
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
setUpSystemResipien();
//load all user from firebase
updateList();
}
}, waktu);
}
}
/* private void loadUserInfo(String email) {
Query userLocation = locationsDatabase.orderByChild("email").equalTo(email);
userLocation.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
/*for (DataSnapshot posSnapshot:dataSnapshot.getChildren()) {
information track = posSnapshot.getValue(information.class);
String namanya = track.getNama();
nama.setText(track.getNama());
alamat.setText(track.getNalamat());
goldar.setText(track.getGolDar());
telpon.setText(track.getNoTelpon());
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
*/
private void getLastLocation () {
fused.getLastLocation().addOnSuccessListener(this, new OnSuccessListener<Location>() {
@Override
public void onSuccess(Location location) {
locationsDatabase.child(FirebaseAuth.getInstance().getCurrentUser().getUid()).setValue(new tracking(
FirebaseAuth.getInstance().getCurrentUser().getEmail()
,FirebaseAuth.getInstance().getCurrentUser().getUid()
, String.valueOf(location.getLatitude())
, String.valueOf(location.getLongitude())
, nama.getText().toString()
, alamat.getText().toString().trim()
,goldar.getText().toString().trim()
,telpon.getText().toString().trim()));
Toast.makeText(listOnline.this, "get location", Toast.LENGTH_LONG).show();
}
});
}
private void updateList() {
firebaseRecyclerAdapter = new FirebaseRecyclerAdapter<information, listOnlineViewHolder>(
information.class, R.layout.user_online,
listOnlineViewHolder.class,
counterRef) {
@Override
protected void populateViewHolder(final listOnlineViewHolder viewHolder, final information model, int position) {
viewHolder.teksemail.setText(model.getEmail());
viewHolder.namanya.setText(model.getNama());
// Query userInfromation = databaseReference.orderByChild("email").equalTo(model.getEmail());
/* userInfromation.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
for (DataSnapshot posSnapshot:dataSnapshot.getChildren()) {
information info = posSnapshot.getValue(information.class);
String name = dataSnapshot.child("nama").getValue(String.class);
String goldar = dataSnapshot.child("golDar").getValue(String.class);
viewHolder.namanya.setText(name);
viewHolder.golongannya.setText(goldar);
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
*/
viewHolder.setItemClickListener(new ItemClickListener() {
@Override
public void onClick(View view, int position) {
fused.getLastLocation().addOnSuccessListener(new OnSuccessListener<Location>() {
@Override
public void onSuccess(Location location) {
Intent map = new Intent(listOnline.this, trackingMaps.class);
map.putExtra("email", model.getEmail());
map.putExtra("lat", location.getLatitude());
map.putExtra("lnt", location.getLongitude());
startActivity(map);
}
});
// }
}
});
}
};
firebaseRecyclerAdapter.notifyDataSetChanged();
list.setAdapter(firebaseRecyclerAdapter);
}
//buat setup untuk resipien
private void setUpSystem() {
onlineRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
if (dataSnapshot.getValue(Boolean.class)) {
currentUserRef.onDisconnect().removeValue();
counterRef.child(FirebaseAuth.getInstance().getCurrentUser().getUid()).
setValue(new user(FirebaseAuth.getInstance().getCurrentUser().getEmail(), "online"
,nama.getText().toString(),goldar.getText().toString()));
firebaseRecyclerAdapter.notifyDataSetChanged();
}
counterRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
for (DataSnapshot postSnapshot:dataSnapshot.getChildren()) {
user us = postSnapshot.getValue(user.class);
// Log.d("LOG", ""+us.getEmail()+"is"+us.getNamadia());
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
Я пыталсянайти решение, но не смог его найти. Я действительно надеюсь, что вы можете мне помочь. спасибо!
это мой XML, содержащий ваши текстовые просмотры
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardElevation="10dp"
android:layout_margin="16dp"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp">
<TextView
android:layout_weight="8"
android:textSize="24sp"
android:text="test@gmail.com"
android:id="@+id/teksemail"
android:textColor="#000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/namanya"
android:text="nama"
android:textSize="16dp"
android:layout_below="@+id/teksemail"
android:textColor="#000"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/golongan"
android:text="golongan"
android:textSize="16dp"
android:layout_below="@+id/namanya"
android:textColor="#000"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:src="@mipmap/ic_launcher"/>
</RelativeLayout>
</androidx.cardview.widget.CardView>