Is there an addHeaderView equivalent for RecyclerView?

There isn’t an easy way like listview.addHeaderView() but you can achieve this by adding a type to your adapter for header. Here is an example public class HeaderAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { private static final int TYPE_HEADER = 0; private static final int TYPE_ITEM = 1; String[] data; public HeaderAdapter(String[] data) { this.data = data; } … Read more

Is there an easy way to add a border to the top and bottom of an Android View?

In android 2.2 you could do the following. Create an xml drawable such as /res/drawable/textlines.xml and assign this as a TextView’s background property. <TextView android:text=”My text with lines above and below” android:background=”@drawable/textlines” /> /res/drawable/textlines.xml <?xml version=”1.0″ encoding=”utf-8″?> <layer-list xmlns:android=”http://schemas.android.com/apk/res/android” > <item> <shape android:shape=”rectangle”> <stroke android:width=”1dp” android:color=”#FF000000″ /> <solid android:color=”#FFDDDDDD” /> </shape> </item> <item android:top=”1dp” android:bottom=”1dp”> … Read more

What is the main purpose of setTag() getTag() methods of View?

Let’s say you generate a bunch of views that are similar. You could set an OnClickListener for each view individually: button1.setOnClickListener(new OnClickListener … ); button2.setOnClickListener(new OnClickListener … ); … Then you have to create a unique onClick method for each view even if they do the similar things, like: public void onClick(View v) { doAction(1); … Read more

Android basics: running code in the UI thread

None of those are precisely the same, though they will all have the same net effect. The difference between the first and the second is that if you happen to be on the main application thread when executing the code, the first one (runOnUiThread()) will execute the Runnable immediately. The second one (post()) always puts … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)