Mohammed Azeem

Ranch Hand
+ Follow
since Aug 17, 2012
Cows and Likes
Cows
Total received
3
In last 30 days
0
Total given
0
Likes
Total received
3
Received in last 30 days
1
Total given
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mohammed Azeem

Good Afternoon.

I am proficient in Java and now studying the basics of Android App Development.

I want to re-use the layout activity_main.xm  for a second activity to avoid the laborious work of having to re-create it in the layout editor.
In other words I want to sub-class the Activity ActivityMain but also "sub-class" its layout.

Any suggestion ?

I have searched and searched the web without success.

Thanks,
Mohammed.
6 days ago
No I'm sorry it is not solved

The info I found does not answer my query.

Any suggestions most welcome.

Mohammed.
6 days ago
Solved. Answer in official android tutorials.

If you already have a layout and want to create an alternative version to optimize the layout for different screen sizes or orientations, follow these steps:
1. Open your original layout file and be sure you're viewing the design editor (click the Design tab at the bottom of the window).
2. Click Orientation for Preview   in the toolbar. In the dropdown list, either click a suggested variant such as Create Landscape Variant and you're done, or click Create Other and continue to the next step.
3. In the dialog that appears, you simply need to define the resource qualifiers for the directory name. You can type it in Directory name or select from the Available qualifiers list, one at a time, and click Add  .
4. Once you've added all your qualifiers, click OK.
When you have multiple variations of the same layout, you can easily switch between them from the list that appears when you click Layout Variants  .



6 days ago
Solved. The answer is in the official android tutorials:

If you already have a layout and want to create an alternative version to optimize the layout for different screen sizes or orientations, follow these steps:
1. Open your original layout file and be sure you're viewing the design editor (click the Design tab at the bottom of the window).
2. Click Orientation for Preview   in the toolbar. In the dropdown list, either click a suggested variant such as Create Landscape Variant and you're done, or click Create Other and continue to the next step.
3. In the dialog that appears, you simply need to define the resource qualifiers for the directory name. You can type it in Directory name or select from the Available qualifiers list, one at a time, and click Add  .
4. Once you've added all your qualifiers, click OK.
When you have multiple variations of the same layout, you can easily switch between them from the list that appears when you click Layout Variants  .



6 days ago
Good Afternoon.

I am proficient in Java and now studying the basics of Android App Development.

I want to re-use the layout activity_main.xm  for a second activity to avoid the laborious work of having to re-create it in the layout editor.
In other words I want to sub-class the Activity ActivityMain but also "sub-class" its layout.

Any suggestion ?

I have searched and searched the web without success.

Thanks,
Mohammed.
6 days ago
Good Afternoon,

I am proficient in Java and now I am studying basics of Android Development in Android Studio.

I want to re-use the layout activity_main.xml in another activity to save the laborious work of re-creating it in the layout editor.
In other words I want to sub-class MainActivity but also "sub-class" its layout.

Any suggestion ?

I have searched, and searched the web for an answer without success.

Thanks
Mohammed.
6 days ago
Thank you Tim, you must have posted just as I was typing.
1 week ago
Hello again,

I vaguely recall hash numbers and I think there is a similarity between them and key-value pairs.

I've also watched a few youtube videos and this is my (imperfect) understanding:

* keys map a single label to a collection of related values (e.g bank account (label) to account name, balance etc)
* therefore the key must be unique
* so the key must not change - it must be declared as a final string.

I have tested my hypothesis as follows:

* I have assigned EXTRA_MESSAGE any old literal - the app still works
* I have declared EXTRA_MESSAGE but left it unassigned - the app still works as it should.
* Ihave declared EXTRA_MESSAGE as non-final - and the code still works (though I appreciated why it should be final).

1 week ago
Good Morning,

I am fairly proficient in Java and now I would like to put it to the test by exploring Android Application Development.

My questions are, in the listing below (taken from the official online android tutorials):

* Why is the key EXTRA_MESSAGE defined as a final string ?
* And is there any significance in literal value "com.example.myfirstapp.MESSAGE" ?  Would any literal do? (I will test this)
*

Thanks for any replies.

1 week ago
Hello,

I get slightly obsessed with little details which are often  beyond the scope of my immediate study purposes but I can't move on until they're resolved. I don't know whether this is a good or bad thing.

Anyway,

Suppose str1 refers to one String object and str2 refers to another, and I want to compare these for equaility.

The equals() method of str1 object essentially compares its own private final value with that that of the second string. How does it again access to the other sting object's private final value ?

Thanks for any responses.

Mohammed.
8 months ago
OK, thanks Campbell.

I extend classes willy-nilly.

So is it good practice to provide a no-parameter constructor in my own classes in case I or others wish to extend it, or is it up to users to look at the documentation to see which constructors are available ?
1 year ago
Good Evening,

I've been playing around constructors and inheritance.

I know that constructors are not inherited but those of a base class can be referred to by 'super'.

So what happens when, the derived class has no user-defined constructor but the base class does ?


In the following code:
  *   class A extends B.
  *   A is given a user-defined constructor; B is not.  So the compile ought to provide it with the construtor:
        equivalent to:
       

  *  The code fails unless line 21 is uncommented

All insights greatly appreciated,

Mohammed.



1 year ago
Hello Stephan,

Of course. I can be incredibly stupid sometimes. I don't know how I'm going to pass the test!

I've been trying something similar but I've been defining i outside the loop and inside it getting the compilation errors.
1 year ago
Good Afternoon,

I'm studying flow control in the OCA guide and was just playing around with post increment unary operators in loop conditions.

The code below outputs:

20
21

The for-loop between lines 26-29 terminates on its second pass but I have a suspicion that the iteration variable i is STILL incremented.
But i can't be referred to after the loop terminates because it is local to it, so there's no way of knowing if it was post-incremented or not.

How can I prove that i was indeed post-incremented after the condition failed ?

This isn't directly concerned with certification but thought it interesting for future reference.

All posts appreciated.

1 year ago