Okhelp.cz

Recepty, články, nápady, programování. Dříve dum-zahrada, finance, internet a know-how.okhelp.cz Pro lepší výsledky hledání používejte i diakritiku.

AlertDialog setButton Deprecated



Solution:

public void alertMy(String sTitle, String sMessage){
	AlertDialog.Builder builder = new AlertDialog.Builder(Test.this); // activity
  builder.setTitle(sTitle)
  .setMessage(sMessage)
  .setCancelable(false)
  .setNegativeButton("Close",new DialogInterface.OnClickListener() {
      public void onClick(DialogInterface dialog, int id) {
          dialog.cancel();
      }
  });
  AlertDialog alert = builder.create();
  alert.show();

}


397LW NO topic_id



Další témata ....(Topics)


388

Android Studio Gradle Download Link | android-studio-gradle-download-link


I You use offline work for better building speed of project or for other purpose
https://gradle.org/releases

Offline work:
File - Settings - Gradle
- select Use local gradle distribution
- select path Gradle home:
- check Offline work
297

Shuffle array int string Java Android | shuffle-array-int-string-java-android



String [] arOfStrings = {"one", "two", "three"};
List<String> mListOfStrings = new ArrayList<String>(Arrays.asList(arOfStrings));
Collections.shuffle(mListOfstrings);
String str = mListOfStrings.get(2);// 2 is index of pozition an element


int [] arOfInt = {1, 2, 3};
List<Integer> mListOfInt = new ArrayList<Integer>(Arrays.asList(arOfInt));
Collections.shuffle(mListOfInt);
236

tag should specify a target API level Warning | uses-sdk-tag-should-specify-target-api


Warning in AndroidManifest.xml:
tag should specify a target API level (the highest verified version; when running on
later versions, compatibility behaviors may be enabled) with android:targetSdkVersion="?"

Solution:

    <uses-sdk android:minSdkVersion="4"
         android:targetSdkVersion="16" />
250

Resize ImageView Image in View Android Example | resize-imageview-image-in-view-android-example


How to resize an image in ImageView Android source code.
Resize imageview layout and image will resize too:

	public void resizeImageView(int width, int height) {
		final ImageView picture1 = (ImageView)findViewById(R.id.imageView1);
		LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(width, height);
		picture1.setLayoutParams(layoutParams);
	}

264

Font Family change on View dynamically Android Example | font-family-change-on-view-android-example


TypeFace, setTypeface, font, font family, array of String, Button create dynamically

@Override
protected void onStart() {
LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(
  48,
  55
);	
Typeface typeFace = Typeface.MONOSPACE;	
String [] ar = {"A","B","C","D","E","F","G","H","J","K"};
for (int i = 0; i < ar.length; i++) {
Button buttonView = new Button(this);
buttonView.setText(Html.fromHtml("<b>"+ar[i]+"</b>"));
buttonView.setTextColor(Color.BLUE);
buttonView.setTextSize(27.f);
buttonView.setTypeface(typeFace,Typeface.BOLD);
buttonView.setOnClickListener(mThisButtonListener);
if(i%2==0)
	mLayoutButtons.addView(buttonView, p);
else
	mLayoutButtonsNextRow.addView(buttonView, p);
	
_listOfButtons.add(buttonView);
}

	super.onStart();
}

//////// xml file
<TextView
    android:id="@+id/text01"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="20dp"
    android:fontFamily="Arial"
 />


Editace Jana Žákovská : 2013-12-09 10:06:10
Počet článků v kategorii: 397
Url:alertdialog-setbutton-deprecated
Share
Share
Tweet