Set Custom Font to View Android Example
You have to put your font fonts/samplefont.ttf into assets/fonts folder in your project!
// set own custom font from assets
TextView txt = (TextView) findViewById(R.id.custom_font);
Typeface mFace = Typeface.createFromAsset(getContext().getAssets(),
"fonts/samplefont.ttf");
txt.setTypeface(mFace);
396LW NO topic_id
AD
Další témata ....(Topics)
Try some solution - each individually or all
- Check AndroidManifest.xml activity declaration
<activity android:name=".EnableProfileActivity" android:label="@string/app_name" />
- Delete BUILD folder in module tree and Clean / Rebuild project
- Restart Android Studio
First cteate big icon 512x512 px formtat .PGN in graphics editor as Photoshop, Gimp, Piant.NET and save image.
If you create new project via Eclipse and choice your 512x512 image for ic_launcher.
Eclipse will make all icons from this image for new application very well.
If you create new project via Eclipse and choice your 512x512 image for ic_launcher.
Eclipse will make all icons from this image for new application very well.
Errors:
E/Ads(333): The android:configChanges value of the com.google.ads.AdActivity must include screenLayout.
E/Ads(333): The android:configChanges value of the com.google.ads.AdActivity must include uiMode.
E/Ads(333): The android:configChanges value of the com.google.ads.AdActivity must include screenSize.
E/Ads(333): The android:configChanges value of the com.google.ads.AdActivity must include smallestScreenSize.
E/Ads(333): You must have AdActivity declared in AndroidManifest.xml with configChanges.
Solution:
Try to using a lower version of the GoogleAdMobAdsSDK ADS SDK in project:
GoogleAdMobAdsSDK-4.0.4
How add SDK to project
Add activity to AndroidManifest.xml
E/Ads(333): The android:configChanges value of the com.google.ads.AdActivity must include screenLayout.
E/Ads(333): The android:configChanges value of the com.google.ads.AdActivity must include uiMode.
E/Ads(333): The android:configChanges value of the com.google.ads.AdActivity must include screenSize.
E/Ads(333): The android:configChanges value of the com.google.ads.AdActivity must include smallestScreenSize.
E/Ads(333): You must have AdActivity declared in AndroidManifest.xml with configChanges.
Solution:
Try to using a lower version of the GoogleAdMobAdsSDK ADS SDK in project:
GoogleAdMobAdsSDK-4.0.4
How add SDK to project
Add activity to AndroidManifest.xml
// .............. blah
<uses-sdk android:minSdkVersion="4"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application android:icon="@drawable/dicts_ico" android:label="@string/app_name"
>
<meta-data
android:value="a12345_your_number"
android:name="ADMOB_PUBLISHER_ID" />
<activity android:name=".MainStartMenu"
android:label="@string/app_name"
android:configChanges="keyboardHidden|orientation"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Google ads -->
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation"/>
// ......... blah
ImputStream is = this.getResources().openRawResource(R.drawable.colors);
Bitmap mBitmap2 = BitmapFactory.decodeStream(is);
int w = mBitmap2.getWidth();
int h = mBitmap2.getHeight();
// int x , y have to be smaller as w , h
int _color = mBitmap2.getPixel(x, y);
Try this code:
final String ERROR = "my error message....";
private class DownloadWebPageTask extends AsyncTask<String, Void, String> {
// some code and method ..... see AsyncTask
@Override
protected String doInBackground(String... urls) {
URL urlL = null;
try {
urlL = new URL(url);//"//chmi.cz..../"
HttpURLConnection urlConnection = null;
try {
urlConnection = (HttpURLConnection) urlL.openConnection();
InputStream in = new BufferedInputStream(urlConnection.getInputStream());
response = readStream(in);
return response;
} catch (IOException e) {
//throw new RuntimeException(e);
} finally {
if(urlConnection != null)
urlConnection.disconnect();
return ERROR;
}
} catch (MalformedURLException e) {
e.printStackTrace();
return ERROR;
}
}
return response;
}
private String readStream(InputStream is) {
try {
ByteArrayOutputStream bo = new ByteArrayOutputStream();
int i = is.read();
while(i != -1) {
bo.write(i);
i = is.read();
}
return bo.toString();
} catch (IOException e) {
return "";
}
}
Editace: 2013-01-08 15:55:11
Počet článků v kategorii: 396
Url:set-custom-font-to-view-android-example