Search code examples
javaandroidtabletsettext

setText method is not working for tablet but work for phone


I am using the same layout for both phone and tablet but for some reason the text in tablet is not being changed but it changes in phone.I even tried using hard code string for eliminating the case of resources not being found, but still doesn't work. I don't get any error either. Has anyone encountered such problem?

1-I tried using same layout for both tablet and phone. 2-Tried using hard coded text.

view = inflater.inflate(R.layout.base_layout, container, false);
view.findViewById(R.id.include_subbase_dual_horizontal).setVisibility(View.VISIBLE);
    
ConstraintLayout scoreBoardCl = view.findViewById(R.id.score_board_cl);
    scoreBoardCl.setVisibility(View.VISIBLE);
    
TextView subgameScore = view.findViewById(R.id.score_board_subgame_score);
    
TextView allGameScore = view.findViewById(R.id.score_board_all_games_score);
    allGameScore.setText("6565656");

    subgameScore.setText("5454545");

Solution

  • I still don't know what the problem is, but have this solution.

     AlertDialog.Builder builder = new AlertDialog.Builder(context);
            View dialogView = inflater.inflate(R.layout.winning_layout_v2, null);
            builder.setView(dialogView);
            AlertDialog dialog = builder.create();
            TextView subgameScore = dialogView.findViewById(R.id.score_board_subgame_score);
            TextView allGameScore = dialogView.findViewById(R.id.score_board_all_games_score);
            allGameScore.setText("6565656");
            subgameScore.setText("5454545");
            dialog.show();