Note that there are some explanatory texts on larger screens.

plurals
  1. POinheritance of custom activities with overloading setContentView, setListAdapter and etc
    primarykey
    data
    text
    <p>Dear Fellow Developers</p> <p>Need your advice about the architecture design, specifically about the <strong>inheritance of custom activities</strong>. In my case, there is a necessity to create a music application with the exactly same functionally like the original one but with a different UI and behavior.</p> <p>Please, hit me whether the approach described below is right or not. I would appreciate your suggestions how to <strong>use maximally functionalities of already implemented activities</strong>. </p> <p>I think to inherit my track browser, playlist browser, media playback and etc. activities from the standard ones of the original music player. Then I would need to replace the layout and intercept with appropriate handling some events.</p> <p><strong>Challenge 1:</strong> <em>setContentView</em> sets already the layout inside <em>onCreate</em> of an original activity. I need to call <em>super.onCreate</em> in my <em>onCreate</em> and then call <em>setContentView</em> again. I’ve investigated that it’s possible to <a href="https://stackoverflow.com/questions/7052484/calling-setcontentview-multiple-times">call <em>setContentView</em> several times</a> but it’s necessary to instantiate all UI elements each time again. I think that they may be performance and compatibility problems. <strong>My suggestion 1:</strong> overload <em>setContentView</em> and detect if the instance of the appropriate layout is passed. In case it’s we inflate the activity.</p> <p><strong>Challenge 2:</strong> almost all members are private in original activities but I would need to replace the adapter and may be some broadcast receivers loaded in the original activities. <strong>My suggestion 2:</strong> again I can overload <em>setListAdapter</em>, <em>registerReceivers</em> and etc. and check what kind of instances they try to load. If the instances are not ones of my classes I would skip loading them otherwise I would load it.</p> <p>I’m searching a root conception of a big project so I would like to be sure if my thinking is right in advance. Please, point whether I’m not violating conceptions of Android applications design.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload