Android compiled resources – resources.arsc

TL;DR: With the help of android asset packagin tool(aapt), xml nodes get translated to Java classes and the corresponding xml attributes get translated to numerical Ids. Android run-time works with these numeric ids to instantiate classes and create the views TL;R Run this command to dump the binary xml aapt d xmltree apk_file_name res/layout/activity_main.xml(aapt can … Read more

How to play the audio files directly from res/raw folder?

add this code in onItemClickListener. listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View view, int position,long id) { TextView txtView=(TextView)view.findViewById(R.id.txt_view); String fname=txtView.getText().toString().toLowerCase(); int resID=getResources().getIdentifier(fname, “raw”, getPackageName()); MediaPlayer mediaPlayer=MediaPlayer.create(this,resID); mediaPlayer.start(); } });

No generated R.java file in my project [duplicate]

Go to Project and hit Clean. This should, among others, regenerate your R.java file. Also get rid of any import android.R.* statements and then do the clean up I mentioned. Apparently Jonas problem was related to incorrect target build settings. His target build was set to Android 2.1 (SDK v7) where his layout XML used … Read more

How do I add selectableItemBackground to an ImageButton programmatically?

Here is an example using answer here: How to get the attr reference in code? // Create an array of the attributes we want to resolve // using values from a theme // android.R.attr.selectableItemBackground requires API LEVEL 11 int[] attrs = new int[] { android.R.attr.selectableItemBackground /* index 0 */}; // Obtain the styled attributes. ‘themedContext’ … Read more