Pages

Showing posts with label more. Show all posts
Showing posts with label more. Show all posts

Wednesday, March 30, 2016

DialogFragment example something wrong on Android 6 Marshmallow emulator

Its a example to implement DialogFragment. Please check the screenshots of running on Android Emulators of Android 4.1 Jelly Bean with API 16, Android 5.1 Lollipop with API 22 and Android 6.0 Marshmallow with API 23. If the emulator of Android 6.0 Marshmallow work properly, DialogFragment display wrong on Marshmallow.



Check this video:


layout/fragment_dialog.xml, DialogFragment layout.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout

android_padding="10dp"
android_orientation="vertical"
android_layout_width="match_parent"
android_layout_height="match_parent">

<ImageView
android_layout_width="wrap_content"
android_layout_height="wrap_content"
android_src="@mipmap/ic_launcher"/>

<TextView
android_id="@+id/dialogtext"
android_layout_width="match_parent"
android_layout_height="wrap_content"
android_textSize="20dp"
android_textStyle="italic|bold"/>

</LinearLayout>

MainActivity.java with DialogFragment.
package com.blogspot.android_er.androiddialogfragment;

import android.app.DialogFragment;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

EditText inputTextField;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

inputTextField = (EditText)findViewById(R.id.inputtext);
Button btnOpen = (Button)findViewById(R.id.opendialog);
btnOpen.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showDialog();
}
});
}

void showDialog() {
FragmentTransaction ft = getFragmentManager().beginTransaction();
Fragment prev = getFragmentManager().findFragmentByTag("dialog");
if (prev != null) {
ft.remove(prev);
}
ft.addToBackStack(null);

String inputText = inputTextField.getText().toString();

DialogFragment newFragment = MyDialogFragment.newInstance(inputText);
newFragment.show(ft, "dialog");

}

public static class MyDialogFragment extends DialogFragment {

String mText;

static MyDialogFragment newInstance(String text) {
MyDialogFragment f = new MyDialogFragment();

Bundle args = new Bundle();
args.putString("text", text);
f.setArguments(args);

return f;
}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mText = getArguments().getString("text");

}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View dialogView = inflater.inflate(R.layout.fragment_dialog, container, false);
TextView dialogText = (TextView)dialogView.findViewById(R.id.dialogtext);
dialogText.setText(mText);

return dialogView;
}
}
}


layout/activity_main.xml, main layout.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout


android_layout_width="match_parent"
android_layout_height="match_parent"
android_padding="16dp"
android_orientation="vertical"
tools_context=".MainActivity"
android_background="#808080">

<TextView
android_layout_width="wrap_content"
android_layout_height="wrap_content"
android_layout_gravity="center_horizontal"
android_autoLink="web"
android_text="http://android-er.blogspot.com/"
android_textStyle="bold" />

<EditText
android_id="@+id/inputtext"
android_layout_width="match_parent"
android_layout_height="wrap_content"
android_hint="Type something"/>
<Button
android_id="@+id/opendialog"
android_layout_width="match_parent"
android_layout_height="wrap_content"
android_text="Open DialogFragment"
android_textAllCaps="false"/>
</LinearLayout>


reference: http://developer.android.com/reference/android/app/DialogFragment.html


To fixed it, edit layout/fragment_dialog.xml, modify android:layout_width of <ImageView> from "wrap_content" to "match_parent".

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout

android_padding="10dp"
android_orientation="vertical"
android_layout_width="match_parent"
android_layout_height="match_parent">

<ImageView
android_layout_width="match_parent"
android_layout_height="wrap_content"
android_src="@mipmap/ic_launcher"/>

<TextView
android_id="@+id/dialogtext"
android_layout_width="match_parent"
android_layout_height="wrap_content"
android_textSize="20dp"
android_textStyle="italic|bold"/>

</LinearLayout>

android:layout_width="wrap_content"

android:layout_width="match_parent"

Read More..

Wednesday, March 2, 2016

Android Developers Blog Introducing Android 4 1 Jelly Bean preview platform and more

Android Developers Blog: Introducing Android 4.1 (Jelly Bean) preview platform, and more
Read More..

Thursday, February 25, 2016

color:

content,provider,android,developer,tutorial,part,10
Read More..

Saturday, February 13, 2016

Doing More with Java Android and Tomcat Edition

Doing More with Java: Android and Tomcat Edition

This Doing More With book helps you move from introductory Java to more powerful tools and concepts. As you go through the book you get to where you can connect an Android app to a Hibernate/Tomcat server. Unlike many programming books, this one helps you gain all the skills to create mobile connected apps. Using HTTP from Android with JSON, Hibernate, and MySQL a complete JSON Web Service can be created and consumed.

The tone of the book is intended to be light rather than pedantic and hints and tips based on the author’s life experience are included.

Read More..

Sunday, March 9, 2014

Community Update deferred open source and more

Here are some of the recent developments from the greater developer community.

deferred.defer

Nick Johnson recently added a new module to the App Engine Python SDK which allows you to use the task queue service to execute deferred function calls. This library requires minimal configuration and makes it even easier to use tasks. Using it is as simple as calling deferred.defer with the function and arguments you want to call - for example:

from google.appengine.ext import deferred
deferred.defer(logging.info, "In a deferred task")

For more details, see the article.

Ruby as a runtime option

The JRuby App Engine project has done a lot of work making spin-up time less painful with the most recent release. Theyve also had some great contributions from the growing community, such as an Image API that is ImageScience compatible. Ruby programmers can now build applications using familiar tools like Sinatra and DataMapper, while having access to the full set of App Engine APIs for Java. Follow future developments on the jruby-appengine blog and watch for talks by the JRuby App Engine team at upcoming conferences: "Scaling on App Engine with Ruby and Duby" at RubyConf and "JRuby on Google App Engine" at JRubyConf.

An open source alternate environment: TyphoonAE

Open source efforts to provide alternate hosting environments for App Engine applications continue to expand, with the TyphoonAE project joining the existing AppScale project in providing a platform to run App Engine apps. TyphoonAE aims to provide a complete environment for hosting App Engine apps, and so far includes compatible datastore, memcache, task queue and XMPP implementations.

gae-query-pager

Juraj recently created and open sourced a library for the Java runtime which "generate[s] appropriate paging queries from a base query, and then using these queries to page through the data." This is intended to simplify iteration through all of the results in a very large result set.

AEJ Tools

If you love RESTful APIs then it would be worth your while to take a look at AEJ Tools. Their library provides "a server module which provides a Rest style access to your datastore data, and a client module which allows you to run queries remotely using the Groovy interactive console. It can be used to run queries, store new entities or as a data import/export tool."

An open source full text search library

The datastore related libraries just keep right on coming. Full text search is a highly requested feature for App Engine and those behind the open source appengine-search project have create a Python library which "[c]an defer indexing via Task Queue API. Uses Relation index strategy mentioned in Brett Slatkins Google I/O talk."

Testing framework

Moving beyond the datastore, the developers at geewax have created an advanced testing framwork called GAE Testbed. It covers everything from isolated and quick unit tests to full scale end to end tests and builds on some of the great testing tools for App Engine which are already avilable.

Party Chat

In other news, the folks at techwalla have migrated their party chat app to App Engine and made the source code available. It uses the new XMPP API to simulate a chat room using your favorite XMPP client. You can read more specifics on their blog.

Other open source projects

Check out the open source projects wiki page for more open source App Engine applications and utilities. Since the last posting, nearly 15 new applications have been added, so keep checking in as new projects are added regularly. If you have a project of your own to add, just follow the instructions at the bottom of the same page.

Thats brings our community update to a close. Were always interested in hearing about new and interesting projects which use App Engine. If you have something to share, drop us a line.

Read More..