Wednesday, February 26, 2014

How to get all resource id from application in adnroid

How to get all resource id from application in android

This post about how to get all resource id from the application .

From R.id class you can get list of resource id.
  final R.id idResources = new R.id();
              final Class<R.id> c = R.id.class;
              final java.lang.reflect.Field[] fields = c.getDeclaredFields();
      

              for (int i = 0, max = fields.length; i < max; i++) {
                  final int resourceId;
                  try {
                      resourceId = fields[i].getInt(idResources);

Here all resource id will print in console
                      Log.e("ID", "resourceid :: " +resourceId);
             
                  } catch (Exception e) {
                      continue;
                  }
                 
              }

 

Full Source Code
public void chekResourceIDFound( int id){
final R.id idResources = new R.id();
final Class<R.id> c = R.id.class;
final java.lang.reflect.Field[] fields = c.getDeclaredFields();

for (int i = 0, max = fields.length; i < max; i++) {
final int resourceId;
try {
resourceId = fields[i].getInt(idResources);
Log.e("ID", "resourceid :: " +resourceId);

} catch (Exception e) {
continue;
}

}

}

              

Wednesday, February 19, 2014

How to Set findViewById for View Via programmatically in android

How to Set findViewById for View Via programmatically in android


This post about how to set the id for view . When you are creating a view from programmatically.

Create id in the resource
<resources>
      <item type="id" name="my_btn" />
     <item type="id" name="my_imageView" />


</resources>


Set the id for view in Activity Class or where ur creating view

Button btn = new Button(context);
ImageButton image_btn = new ImageButton(context);
btn.setId(R.id.my_btn);
image_btn.setId(R.id.my_imageView);
             
Then Find the view using findViewById .  

image_btn = (ImageButton) findViewById(R.id.my_imageView);
btn = (Button) findViewById(R.id.my_btn);             



Friday, February 14, 2014

How to enable USB Debug mode in MOTO G

How to enable USB Debug mode in MOTO G

This post about how to enable USB debug in Moto g Mobile.
By Default Developer option tab not available in Moto g. so enable the developer option  follow the steps.

1. GOTO  -> Settings -> About Phone ->  Click 7 Times Build Number Tab
2.Then go to setting page you can able see to Developer Option



Step 1 -




Step 2

Check out this may be help you

Related Posts Plugin for WordPress, Blogger...