Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Java Textview properties in ListView do not change

Tual

New Coder
I have a listview, but when I try to change the text color and size of the textview in the listview, it doesn't change, but I don't get an error. I used to get errors when I tried something but now I don't .I do not know how to do it. Here is the image showing the listview enter image description here



Java:
public class MainActivity extends AppCompatActivity {

    DatabaseReference databaseReference;
    List<pdfClass> uploads;
    ListView listview;
    FloatingActionButton floatingActionButton;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        listview = findViewById(R.id.listview);
        floatingActionButton = findViewById(R.id.floatingActionButton);
        uploads = new ArrayList<>();

        viewAllFiles();

        listview.setOnItemClickListener((parent, view, position, id) -> {
            pdfClass pdfupload = uploads.get(position);
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setType("application/pdf");
            intent.setData(Uri.parse(pdfupload.getUrl()));
            startActivity(intent);
        });

        floatingActionButton.setOnClickListener(view->{
            Intent intent = new Intent(getApplicationContext(),UploadPDF.class);
            startActivity(intent);

        });
    }

    private void viewAllFiles() {

        databaseReference = FirebaseDatabase.getInstance().getReference("Uploads");
        databaseReference.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(@NonNull DataSnapshot snapshot) {
                for (DataSnapshot postsnapshot : snapshot.getChildren()){
                    pdfClass pdfClass = postsnapshot.getValue(furkan.demirel.myapplication.pdfClass.class);
                    uploads.add(pdfClass);


                }
                String[] Uploads = new String[uploads.size()];
                for (int i =0;i<Uploads.length;i++){
                    Uploads[i]=uploads.get(i).getName();

                }
                ArrayAdapter<String> adapter= new ArrayAdapter<String>(getApplicationContext(),
                        android.R.layout.simple_list_item_1,Uploads){


                    @NonNull
                    @Override
                    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent){
                        View view = super.getView(position,convertView,parent);
                        TextView text =(TextView) view.findViewById(android.R.id.text1);
                        text.setTextColor(Color.BLACK);
                        text.setTextSize(22);
                        return view;
                    }
                };
                listview.setAdapter(adapter);

            }



            @Override
            public void onCancelled(@NonNull DatabaseError error) {

            }
        });
    }

}
 
My Java is much too rusty for any proper advice. One thing I remember from yore that I had to use a custom renderer to change the color of specific table cells. Maybe that would apply here too ?
 

New Threads

Buy us a coffee!

Back
Top Bottom