-1

I need to show a "No data found" message on many screens in my app. For that I created a separate layout with message and image; Now,I'm not sure whether I should include that layout in all other activities' layout or render this layout at runtime? What would be more efficient? Any suggestion is appreciable.

Thanks;

ManishNegi
  • 569
  • 1
  • 6
  • 19
  • 1
    read this [Dynamic vs XML layout in Android?](https://stackoverflow.com/a/11960645/5305430) – sushildlh Mar 15 '19 at 10:42
  • Thanks, Sushil. My concern is still not clear, do you have any personal opinion on this? – ManishNegi Mar 15 '19 at 10:49
  • As you deleted the answer posted by you. I'm saddened by the thought that people are actually here just for earning reputation points rather than genuinely resolving a problem. @SushilKumar – ManishNegi Mar 15 '19 at 11:42
  • I already given your 2-3 solution but non work for you. – sushildlh Mar 15 '19 at 11:45

1 Answers1

0

I use a textview with text : "No data found" in all layouts and set VISIBILITY GONE or VISIBLE according to api result. Or you can add view to your main layout if no data found. Like this;

public showAlert(LinearLayout layout){
    TextView textView= new TextView(context);
    textView.setText("No data found");
    layout.addView(textView);
}

Write this function in a class and call everywhere you want

Athira
  • 1,177
  • 3
  • 13
  • 35