Author Archives: wpadmin

Create new project in Android Studio as copy of another

With AS closed, use file manager to copy project folder to create another project and change folder name to new name. Go into newproject/app and edit build.gradle (eg in Notepad) to change package name. In same way edit AndroidManifest.xml to … Continue reading

Posted in Android | Leave a comment

drawable not found

I was getting this stack dump, which made it difficult to work out what the problem was. android.content.res.Resources$NotFoundException: Resource ID #0x7f060056 at android.content.res.Resources.getValue(Resources.java:1123) at android.support.v7.widget.AppCompatDrawableManager.loadDrawableFromDelegates(AppCompatDrawableManager.java:328) at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:193) Problem was fixed by moving 2 vector drawables (used in menu) from drawable-v24 … Continue reading

Posted in Android | Leave a comment

no actionbar

When copying projects from an Android sample project I’ve found that when the app runs there is no action bar visible. Solved this by the following. Into the top of the activity put android.support.v7.app.ActionBar ab; Into onCreate put actionBarSetup(); Create … Continue reading

Posted in Android | Leave a comment

new wear app says default activity not found

After creating a new wearable app in Android Studio using its own templates for a watch face, the app would not run, saying ‘default activity not found.’ The simple answer (mentioned here) is to have a simple activity and its … Continue reading

Posted in Android | Leave a comment

Clickable link in textview

Create resource in strings.xml. <string name=”txtCredits”>Support: <a href=”http://www.stackoverflow.com”>click here</a></string> 2. Create textview in layout and assign string. <TextView android:id=”@+id/textLink1″ android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:text=”@string/txtCredits” /> 3. Modify in activity. link1 = (TextView) findViewById(R.id.textLink1); link1.setMovementMethod(LinkMovementMethod.getInstance());  

Posted in Android | Leave a comment

addRule(RelativeLayout.BELOW not working

I needed to create a view dynamically and that was working ok. Then I wanted to add some text beneath that view and I couldn’t get it to work: the text appeared over the top of the first view. The … Continue reading

Posted in Android | Leave a comment

Missed error due to logcat scrolling in Android Studio

I had an activity crashing but could only briefly see the crash report scroll by in the Android Studio logcat before it was cleared and replaced by the restarted activity. Changing ‘Show only selected application’ to ‘Edit filter configuration’ did … Continue reading

Posted in Android | Leave a comment

Restore scroll position on return to listview

Thanks again to stackoverflow. Wanted to position listview at same place it was left when the user clicked on an item to update/view it (in separate activity). To save position – not just of top record but of the offset … Continue reading

Posted in Android | Leave a comment

Update listview after item update

I couldn’t find a way to refresh the listview after returning from updating an item in a separate activity. I couldn’t get any variation of adapter.notifyDataSetChanged() to work, despite it being suggested in many places. What worked for me was … Continue reading

Posted in Android | Leave a comment

onItemClickListener not working

Had list view using custom adapter and found that onItemClickListener would not work. Found answer in stackoverflow. Apparently the listener won’t work if any row item contains a focusable or clickable view. The solution is the following line, which I … Continue reading

Posted in Android | Leave a comment