I would like to have a checkbox preference that takes the user to a new (sub)preference screen if the user presses on the actual text (and not on the checkbox to the right).
Just as the control under Settings - Wireless - Mobile Network Settings - Access Point Names.
I want to create a list like iphone list and HTC hero phone app.
So how can i do that because I tried it with default ListView but I can not make two list in a single layout and ScrollView does not work on it.
So can any body help me about this matter?
My application takes userid from user as input, the userid is alphanumeric i.e just the first character is (a-z), other part is numeric. How can I validate input of this type ( like G34555) ?
I have a ProgressDialog that retrieves in background data from database by executing php script.
I'm using gson Google library. php script is working well when executed from browser:
{"surveys":[{"id_survey":"1","question_survey":"Are you happy with the actual government?","answer_yes":"50","answer_no":"20"}],"success":1}
However, ProgressDialog background treatment is not working well:
@Override
protected Void doInBackground(Void... params) {
String url = "http://192.168.1.4/tn_surveys/get_all_surveys.php";
HttpGet getRequest = new HttpGet(url);
Log.d("GETREQUEST",getRequest.toString());
try {
DefaultHttpClient httpClient = new DefaultHttpClient();
Log.d("URL1",url);
HttpResponse getResponse = httpClient.execute(getRequest);
Log.d("GETRESPONSE",getResponse.toString());
final int statusCode = getResponse.getStatusLine().getStatusCode();
Log.d("STATUSCODE",Integer.toString(statusCode));
Log.d("HTTPSTATUSOK",Integer.toString(HttpStatus.SC_OK));
if (statusCode != HttpStatus.SC_OK) {
Log.w(getClass().getSimpleName(), "Error " + statusCode + " for URL " + url);
return null;
}
HttpEntity getResponseEntity = getResponse.getEntity();
Log.d("RESPONSEENTITY",getResponseEntity.toString());
InputStream httpResponseStream = getResponseEntity.getContent();
Log.d("HTTPRESPONSESTREAM",httpResponseStream.toString());
Reader inputStreamReader = new InputStreamReader(httpResponseStream);
Gson gson = new Gson();
this.response = gson.fromJson(inputStreamReader, Response.class);
}
catch (IOException e) {
getRequest.abort();
Log.w(getClass().getSimpleName(), "Error for URL " + url, e);
}
return null;
}
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
Log.d("HELLO","HELLO");
StringBuilder builder = new StringBuilder();
Log.d("STRINGBUILDER","STRINGBUILDER");
for (Survey survey : this.response.data) {
String x= survey.getQuestion_survey();
Log.d("QUESTION",x);
builder.append(String.format("<br>ID Survey: <b>%s</b><br> <br>Question: <b>%s</b><br> <br>Answer YES: <b>%s</b><br> <br>Answer NO: <b>%s</b><br><br><br>", survey.getId_survey(), survey.getQuestion_survey(),survey.getAnswer_yes(),survey.getAnswer_no()));
}
Log.d("OUT FOR","OUT");
capitalTextView.setText(Html.fromHtml(builder.toString()));
progressDialog.cancel();
}
HELLO Log is displayed.
STRINGBUILDER Log is displayed.
QUESTION Log is NOT displayed.
OUT FOR Log is displayed.
Survey Class:
public class Survey {
int id_survey;
String question_survey;
int answer_yes;
int answer_no;
public Survey() {
this.id_survey = 0;
this.question_survey = "";
this.answer_yes=0;
this.answer_no=0;
}
public int getId_survey() {
return id_survey;
}
public String getQuestion_survey() {
return question_survey;
}
public int getAnswer_yes() {
return answer_yes;
}
public int getAnswer_no() {
return answer_no;
}
}
Response Class:
public class Response {
ArrayList<Survey> data;
public Response() {
data = new ArrayList<Survey>();
}
}
Any help please concerning WHY the FOR loop is not executed.
Thank you for helping.
I would like to show a notification that displays the progress of an
ongoing operation. That works well for me.
But at the same time the remote view should contain cancel button to stop the ongoing operation. The usual content intent should still do something else, i.e. not cancel the ongoing operation. It seems though that I can only have one intent.
I have to specify a contentIntent that is launched when clicking on
the notification: If I don't specify that I get something along those
lines:
E/ActivityManager( 62): Activity Manager Crash
E/ActivityManager( 62): java.lang.IllegalArgumentException: contentIntent required ...
For the "cancel" button I set another intent:
Intent cancelSyncIntent = new Intent("com.xyz.CANCEL_SYNC");
contentView.setOnClickPendingIntent(R.id.cancel_sync,
PendingIntent.getBroadcast(context, 0,
cancelSyncIntent, 0));
But this never works. I always get the content intent when the button
is clicked. It looks like I cannot use buttons in remote views of
notifications?!
I could probably display a text: "<< Press to cancel operation ", but that seems rather heavy handed.
hi
i am implementing registration form adding date field then click icon to display date dialog window then limit date validation in system date below date only how can implement the validation
protected Dialog onCreateDialog(int id)
{
Calendar c = Calendar.getInstance();
int cyear = c.get(Calendar.YEAR);
int cmonth = c.get(Calendar.MONTH);
int cday = c.get(Calendar.DAY_OF_MONTH);
switch (id) {
case DATE_DIALOG_ID:
return new DatePickerDialog(this, mDateSetListener, cyear, cmonth, cday);
}
return null;
}
private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener()
{
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth)
{
String date_selected = String.valueOf(monthOfYear+1)+" /"+String.valueOf(dayOfMonth)+" /"+String.valueOf(year);
EditText birthday=(EditText) findViewById(R.id.EditTextBirthday);
birthday.setText(date_selected);
}
};
public void onClick(View v)
{
if(v == b1)
showDialog(DATE_DIALOG_ID);
}
}
**
showing in system date in below dates only how can implemented
some solution in running year to below years are display not incrementing above years this condition are appliying validations how can implemented ?
I am very new to this, and I more looking for what information I need to study to be able to accomplish this.
What I want to do is use my GUI I have built for my app, but pull the information from a website.
If I have a website that looks like this:
(Sorry, can't post pics yet)
http://
dl.dropbox.com/u/7037695/ErrorCodeApp/FromWebsite.PNG
(full website can be seen at http://www.atmequipment.com/Error-Codes)
What would I need from the website so that if a user entered an error code here:
http://
dl.dropbox.com/u/7037695/ErrorCodeApp/InApp.PNG
It would use the search from the website, and populate the error description in my app?
I know this is a huge question, I'm just looking for what is actually needed to accomplish this, and then I can start researching from there. -- Or is it even possible?
Can anyone tell me how I can Dynamically add groups & children to an ExpandableListView. The purpose is to create a type of task list that I can add new items/groups to.
I can populate the view with pre-filled arrays but of course can't add to them to populate the list further. The other method i tried was using the SimpleExpandableListAdapter. Using this i am able to add groups from a List but when it comes to adding children i can only add 1 item per group.
public List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
public List<List<Map<String, String>>> childData = new ArrayList<List<Map<String, String>>>();
public void addGroup(String group) {
Map curGroupMap = new HashMap();
groupData.add(curGroupMap);
curGroupMap.put(NAME, group);
//Add an empty child or else the app will crash when group is expanded.
List<Map<String, String>> children = new ArrayList<Map<String, String>>();
Map<String, String> curChildMap = new HashMap<String, String>();
children.add(curChildMap);
curChildMap.put(NAME, "EMPTY");
childData.add(children);
updateAdapter();
}
public void addChild(String child) {
List children = new ArrayList();
Map curChildMap = new HashMap();
children.add(curChildMap);
curChildMap.put(NAME, child);
curChildMap.put(IS_EVEN, "This child is even");
childData.add(activeGroup, children);
updateAdapter();
}
While i'm clicking a button in my menu list (for example select all)my application is getting force closed.Why is it so???in eclipse emulator it is working fine,but in phone(i'm using LG620)it's getting force closed,as i've no cable with me,i can't debug it.
final Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setType("image/jpeg");
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "[email protected]" });
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "this is the test");
emailIntent.putExtra(Intent.EXTRA_TEXT, "testing time");
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(url));
if i wanted to reference an int from another class how would i go about doing that???
public class Zoom extends View {
private Drawable image;
public int zoomControler=20;
public Zoom(Context context)
{
super(context);
image=context.getResources().getDrawable(R.drawable.icon);
setFocusable(true);
}
@Override
protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
super.onDraw(canvas);
image.setBounds((getWidth()/2)-zoomControler, (getHeight()/2)-zoomControler, (getWidth()/2)+zoomControler, (getHeight()/2)+zoomControler);
image.draw(canvas);
}
}
class HelloOnTouchListener implements OnTouchListener{
@Override
public boolean onTouch(View arg0, MotionEvent arg1) {
return true;
}
}
in this case i want to reference the zoomControler from the first class in the second helloontouchlistener class
This logic is written in a function with signature
private void showDialog(final AdapterView<? extends Adapter> parent,
String title, String message, final Tag subject)
Is there a better way of doing this?
// refresh adapter
SimpleCursorAdapter adapter;
if (parent.getAdapter() instanceof WrapperListAdapter) {
adapter = (SimpleCursorAdapter) ((WrapperListAdapter) parent.getAdapter()).getWrappedAdapter();
} else {
adapter = (SimpleCursorAdapter) parent.getAdapter();
}
adapter.getCursor().requery();
adapter.notifyDataSetChanged();
Also, is there any point in having AdapterView<? extends Adapter> in the signature and not just AdapterView<?>?
I am trying to swap the position of two buttons.
my swapping code looks as below.
private void exchangeButtons(Button btn1, Button btn2) {
// Create the animation set
AnimationSet exchangeAnimation = new AnimationSet(true);
TranslateAnimation translate = new TranslateAnimation( Animation.RELATIVE_TO_SELF, btn2.getLeft(),
Animation.RELATIVE_TO_SELF, btn1.getLeft(),
Animation.RELATIVE_TO_SELF, btn2.getRight(),
Animation.RELATIVE_TO_SELF, btn1.getRight()
);
translate.setDuration(500);
exchangeAnimation.addAnimation(translate);
// int fromX = btn1.getLeft();
// int fromY = btn1.getRight();
// int toX = btn2.getLeft();
// int toY = btn2.getRight();
Log.d("ArrangeMe", "view1 pos:" + btn1.getLeft() + ", " +btn1.getRight() + "view2 pos:" + btn2.getLeft() + ", " + btn2.getRight());
AnimationSet exchangeAnimation1 = new AnimationSet(true);
TranslateAnimation translate1 = new TranslateAnimation( Animation.RELATIVE_TO_SELF, btn1.getLeft(),
Animation.RELATIVE_TO_SELF, btn2.getLeft(),
Animation.RELATIVE_TO_SELF, btn1.getRight(),
Animation.RELATIVE_TO_SELF, btn2.getRight()
);
translate1.setDuration(500);
exchangeAnimation1.addAnimation(translate1);
// EXECUTE
btn1.startAnimation(exchangeAnimation);
btn2.startAnimation(exchangeAnimation1);
}
I call the code as below
exchangeButtons(button1, button2);
my layout looks as below
what happens when i execute the code is,
instead of the buttons exchanging their positions, they just disappear for sometime[may be 500 ms] and reappear as they were originally.
how to resolve this problem ? will it work properly in device ?
regards
Hello everybody!
I have a business need to create the NinePatchDrawable objects at runtime, this is, an exterior .png image is received from a server and it has to be applied in a button's background (for example) as a nine patch.
I have tried to create the NinePatchDrawable object, but the constructor asks me for a "byte[] chuck" that describes the patch. The thing is, I have no idea on how to build this chunck from a bitmap that does not have the 9patch information in it.
Any ideas on this topic? Am I seeing the problem from a wrong perpective?
Thanks!
Hey all,
I would like to make a Google map overlay with changable pins. An easy way to visualize this would be to think of a near real time overlay, where the pins are constantly changing location.
However, I can't seem to think of a safe way to do this with the ItemizedOverlay. The problem seems to be the call to populate - If size() is called by some maps thread, and then my data changes, then the result when the maps call accesses getItem() can be an IndexOutOfBoundsException.
Can anyone think of a better solution than overloading populate and wrapping super.populate in a synchronized block?
Perhaps I could get better luck using a normal Overlay? The Itemized one seems to exist to manage the data for you, perhaps I am making a fundamental mistake by using it?
Thanks for any help, my brain is hurting!
Hamy
dear friends,
i have created custom list view using
class EfficientAdapter extends BaseAdapter implements
{
private LayoutInflater mInflater;
private Context context;
public EfficientAdapter(Context context) {
mInflater = LayoutInflater.from(context);
this.context = context;
}
public View getView(final int position, View convertView,
ViewGroup parent) {
ViewHolder holder;
convertView = mInflater.inflate(R.layout.adaptor_content, null);
convertView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
}
});
}
and other necessary methods... also
}
using touch screen when i click on list item OnClickListener of list item is called.
but when i use Mouse Ball / Track Ball (Phone Hardware) to click on ListItem OnClickListener of list item is not called.
can any one guide me is this Phone bug or My Fault?
any help would be appriciated.
For my AutoCompleteTextView I need to fetch the data from a webservice. As it can take a little time I do not want UI thread to be not responsive, so I need somehow to fetch the data in a separate thread. For example, while fetching data from SQLite DB, it is very easy done with CursorAdapter method - runQueryOnBackgroundThread. I was looking around to other adapters like ArrayAdapter, BaseAdapter, but could not find anything similar...
Is there an easy way how to achieve this? I cannot simply use ArrayAdapter directly, as the suggestions list is dynamic - I always fetch the suggestions list depending on user input, so it cannot be pre-fetched and cached for further use...
If someone could give some tips or examples on this topic - would be great!
Hi,
Can someone tell if why when starting an activity with startActivity(intent) , calling getParent() in onCreate() of the new created activity returns a nul ?
Also how could I obtain the parent of an activity created in such a way ? Can a reference of the activity below the current activity in the activity stack be obtained ?
I am looking for an example of using a WebViewClient with shouldOverrideUrlLoading and using HttpPost.
I need to display a web page, keep it within my layout boundaries so it can not launch a new browser and also use HttpPost to send data to the host.
Hi
I defined a remote service over a AIDL file. Now i want to access this service in a different application. But how can I do that? The AIDL file is not accessible in my second application, and if i just copy the AIDL file, then the service can^^t be found.
Any hints for that problem??
Thanks Sebi
I'm using a TableLayout for an Activity and if I have more than a certain number of TableRows a vertical line appears to the right of the screen.
If I use fewer Views in my layout, the line disappears. If this is not a bug, where should I look in my layout for problems?
I was following the progress dialog example in the ApiDemos.
all went great except for one thing - I want to remove the numbers that appear underneath the bar (those running numbers that run from 0 to .getMax().
couldn't find how to do it.
anyone?
Ori
Hello,
Sorry, this's my first time to ask a question here. So, I don't have the permission to upload the image to describe. Never Mind. What I would like to make is a row of ListView like this. The block on the left is an icon.
Much appreciated if you could feedback the correct XML tags. Thanks.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-------
| | some text some text
| | some text some text
-------
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~