How to get a special layout xml file in another application
by quill » Fri, 13 Mar 2009 13:09:58 GMT
Sponsored Links
Hi, guys,
I want to inflate a layout xml file(in different apk), so I use
res = getPackageManager().getResourcesForApplication(appname); to get
the resource; and than use mInflater.inflate(res.getLayout(resId),
null); to inflate the layout.
The problem is, when the xml file is defined as follows:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=" http://schemas.android.com/apk/res/
android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="hello"---------------------------------------->note
this
/>
</LinearLayout>
It works correctly, the text "hello" will be show on the screen.
But when I defined the xml file like this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=" http://schemas.android.com/apk/res/
android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"--------------------------------------
/>
</LinearLayout>
you know, the text was difined by string ids, so when my application
load this, it can't find the string id. How can I do?
--~--~---------~--~----~------------~-------~--~----~
Other Threads
1. Starting Google Maps at pre-specified location
Well, clearify, what I've said:
I'm using next code in order to open Google Maps at "London" (for
instance).
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.query); //my first layout with button
Button searchbutton = (Button) findViewById(R.id.Button01); //
simple button, when click by user comes - Maps are opened
searchbutton.setOnClickListener(new OnClickListener(){
public void onClick(View view) {
openmap
(); //method
that opens Maps (see below)
}});
}
private void openmap(){
//Now starting Intent with parameters, open a MyMap.class, where magic
happens - map appears, but on standard North American view...
Intent i = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse
("geo:0,0?=London"), this, MyMap.class);
startActivityForResult(i, ACTIVITY_CREATE);
}
}
What it could be? Any ideas?
2. Contact List With Header
Hello,
I want to create a Contact List with a navigation header. I'll
explain, my application contains a navigation menu bar with 3 options,
one of those is Contacts. I want the user to be able to click on
Contacts, going to contacts section preserving the same navigation
menu bar.
So far I can not do this because the way SimpleCursorAdapter and
setAdapter works. When I try I get my navigation menu bar repeated for
each contact.
I'm using the example from the following URL:
http://androidforums.com/android-developers/5315-contact-list.html
Thanks in advance!
Rodrigo
3. SMS inbox
4. XML and Programmatic Layout together
5. Accelerometer on Motorola Droid
6. Best Server for Android MultiPlayer Games?
7. SDK and NDK. Additional possibilities