InterviewSolution
| 1. |
Consider a situation in which you are downloading a large file in your app and suddenly the battery goes critically low, you don’t want the download to stop abruptly and would like to show the user a notification/dialog so that he can pause the download. How you will achieve this in android application? |
|
Answer» findViewById is a method that finds the view from the layout resource file that is attached to the current Activity. This method refers to a view with REQUESTED viewId. is already created and exists. If you do not call findViewById for some view, then nothing changes. Button button1 = (Button) findViewById(R.id.button1); TextView topLeft = (TextView) findViewById(R.id.textView2);There is a disadvantage of findViewById() returns a View if it exists in the layout you provided in setContentView(), otherwise it returns NULL at runtime. There is no compile time check for this method.
Android data binding generates binding classes at compile time for layouts. <data> <variable name="user" type="com.example.databindingsample.User" /> </data>We have to add data<> tag before the UI view root within the layout tag. It will bind OBJECT . data<> element can have multiple variable<> tag within it. Those are using to describe a property that can be used within the layout. |
|