View FromHtmlImageActivity.java
public class FromHtmlImageActivity extends Activity { | |
private TextView sampleTextView; | |
private Spanned spannedValue; | |
private String stringWithHtml; | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.main); |
View MyFragment.java
public class MyFragment extends Fragment { | |
@Override | |
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) { | |
View view = inflater.inflate(R.layout.my_fragment, container, false); | |
// Find your buttons in view, set up onclicks, set up callbacks to your parent fragment or activity here. | |
// You can create ViewHolder or separate method for that. | |
// example of accessing views: TextView textViewExample = (TextView) view.findViewById(R.id.text_view_example); | |
// textViewExample.setText("example"); |
View BitmapLruCache.java
package com.github.volley.example.toolbox; | |
import com.android.volley.toolbox.ImageLoader.ImageCache; | |
import android.graphics.Bitmap; | |
import android.support.v4.util.LruCache; | |
public class BitmapLruCache extends LruCache<String, Bitmap> implements ImageCache { | |
public BitmapLruCache(int maxSize) { | |
super(maxSize); |
View VolleyHelper.java
package com.github.volley.example.toolbox; | |
import android.content.Context; | |
import com.android.volley.RequestQueue; | |
import com.android.volley.toolbox.ImageLoader; | |
import com.android.volley.toolbox.Volley; | |
import com.github.volley.example.toolbox.BitmapLruCache; | |
/** |
View VolleyImageSnippet.java
imageView = (ImageView) findViewById(R.id.iv_image); | |
// ... | |
String imageUrl = "http://www.example.com/image.jpg"; | |
VolleyHelper.init(this); // we can call this method in other place - e.g. in class extending Application class | |
// and refer to application context insted of activity context | |
ImageLoader imageLoader = VolleyHelper.getImageLoader(); |
View justified_textview.css
body { | |
font-size: 1.0em; | |
color: rgb(0,0,0); | |
text-align: justify; | |
/* background: rgba(217, 217, 217, 1.0); you can set your background here, | |
it's kind of fix for older versions of Android OS */ | |
} | |
@media screen and (-webkit-device-pixel-ratio: 1.5) { | |
/* CSS for high-density screens */ |
View JustifiedTextView.java
package com.github.sample.view; | |
import android.content.Context; | |
import android.content.res.TypedArray; | |
import android.graphics.Color; | |
import android.os.Build; | |
import android.text.TextUtils; | |
import android.util.AttributeSet; | |
import android.util.TypedValue; | |
import android.view.View; |
View attrs.xml
<declare-styleable name="JustifiedTextView"> | |
<attr name="text" format="reference" /> | |
</declare-styleable> |
View layout_with_justifiedtextview.xml
<com.github.sample.view.JustifiedTextView | |
android:id="@+id/tv_information" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" /> |
View justifiedTextViewActivity.java
// ... | |
private JustifiedTextView tvInformation; | |
public void onCreate() { | |
tvInformation = (JustifiedTextView) findViewById(R.id.tv_information); | |
tVinformation.setText("sample text"); | |
} | |
// ... |