Skip to content

Instantly share code, notes, and snippets.

@2no
Created January 8, 2012 20:42
Show Gist options
  • Save 2no/1579617 to your computer and use it in GitHub Desktop.
Save 2no/1579617 to your computer and use it in GitHub Desktop.
com.android.internal.R のリソースにアクセス
package com.wakuworks.test;
import android.app.Activity;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
// 例)QuickSearchBox の表示
// 参考:http://mpigulski.blogspot.com/2011/03/accessing-comandroidinternalr-resources.html
public class SearchBarActivity extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
int id = Resources.getSystem().getIdentifier("search_bar", "layout", "android");
LinearLayout linearLayout = new LinearLayout(this);
LayoutInflater factory = LayoutInflater.from(this);
factory.inflate(id, linearLayout);
setContentView(linearLayout);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment