Monday, May 5, 2014

Help: fragment under listview.setOnItemClickListener () void


In the main Activity using fragment implements a tab (tab1), tab1 display data using listview, listview layout of each line in a separate xml definition.
1.xml part of the code
1.1, the definition
main.xml part in tabhostandroid: id = "@ android: id / tabhost"
android: layout_width = "match_parent"
android: layout_height = "match_parent">
android: layout_width = "match_parent"
android: layout_height = "match_parent"
android: orientation = "vertical">
android: id = "@ android: id / tabs"
android: layout_width = "match_parent"
android: layout_height = "wrap_content">

android: id = "@ android: id / tabcontent"
android: layout_width = "match_parent"
android: layout_height = "match_parent">

android: id = "@ + id/tab1"
android: layout_width = "match_parent"
android: layout_height = "match_parent" />



1.2.tab1 the xml definition of
xmlns: tools = "http://schemas.android.com/tools"
android: layout_width = "match_parent"
android: layout_height = "match_parent"
android: paddingBottom = "@ dimen / activity_vertical_margin"
android: paddingLeft = "@ dimen / activity_horizontal_margin"
android: paddingRight = "@ dimen / activity_horizontal_margin"
android: paddingTop = "@ dimen / activity_vertical_margin">

android: id = "@ + id/listView1"
android: layout_width = "match_parent"
android: layout_height = "match_parent">



1.3.listview defined in xml
each row
android: id = "@ + id/widget32"
android: layout_width = "match_parent"
android: layout_height = "match_parent"
android: padding = "5dp"
android: descendantFocusability = "blocksDescendants"
android: focusable = "true"
xmlns: android = "http://schemas.android.com/apk/res/android">
android: id = "@ + id / listImageView"
android: layout_width = "50dp"
android: layout_height = "50dp"
android: layout_weight = "1"
android: focusable = "false"
android: clickable = "false"
android: focusableInTouchMode = "false"
android: src = "@ android: drawable / btn_star" />
android: id = "@ + id/widget34"
android: layout_width = "wrap_content"
android: layout_height = "50dp"
android: layout_weight = "9"
android: focusable = "false"
android: clickable = "false"
android: focusableInTouchMode = "false"
android: orientation = "vertical">
android: id = "@ + id/widget35"
android: layout_width = "fill_parent"
android: layout_height = "50dp"
android: layout_weight = "9"
android: focusable = "false"
android: clickable = "false"
android: focusableInTouchMode = "false"
android: orientation = "horizontal">
android: id = "@ + id/textListInfo1"
android: layout_width = "fill_parent"
android: layout_weight = "3"
android: layout_height = "25dp"
android: focusable = "false"
android: clickable = "false"
android: focusableInTouchMode = "false"
android: text = "home appliances" />

android: id = "@ + id/textListInfo2"
android: layout_width = "fill_parent"
android: layout_weight = "3"
android: layout_height = "25dp"
android: focusable = "false"
android: clickable = "false"
android: focusableInTouchMode = "false"
android: text = "machinery" />




2.java code
2.1 main Activity
protected void onCreate (Bundle savedInstanceState) {

super.onCreate (savedInstanceState);
setContentView (R.layout.activity_main);

setupViews ();
}
private void setupViews () {
TabHost tabhost = (TabHost) findViewById (android.R.id.tabhost);
tabhost.setup ();
tabhost.addTab (tabhost.newTabSpec ("tab1") setIndicator ("tab1") setContent (R.id.tab1)..);
tab_fragment1 tab1 = new tab_fragment1 ();
FragmentManager fm = this.getSupportFragmentManager ();
FragmentTransaction ft = fm.beginTransaction ();
ft.add (tab1, "tab1");

ft.commit ();
}
2.1 tab1 code
public View onCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
Log.v ("MyFragment1", "OnCreateView .......");
View v = inflater.inflate (R.layout.activity_tab_fragment1, container, false);
listView = (ListView) v.findViewById (R.id.listView1);
adapter = new LoaderAdapter (10, v.getContext (), R.layout.activity_ent001000_list_item, URLS);
listView.setAdapter (adapter);
listView.setOnScrollListener (mScrollListener);
listView.setClickable (true);
listView.setOnItemClickListener (mItemClickListener);
return v;

}
OnItemClickListener mItemClickListener = new AdapterView.OnItemClickListener ()
{

@ Override
public void onItemClick (AdapterView arg0, View arg1, int arg2,
long arg3) {
/ / TODO Auto-generated method stub
listView.getSelectedView () setBackgroundColor (Color.GRAY);.
System.out.println ("You click on the first" + arg3 + "items");
}

};

After running in a virtual machine, the mouse does not have any reaction on the listview also detail what has given the information, set breakpoints in the onitemclick can not walk in.
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
See if it is a problem with this code, I tested itemclick can respond

listView.getSelectedView () setBackgroundColor (Color.GRAY).;
Reply:
Thank you for your answer first, comment out the code is useless! Is there any place to set permissions, for example Manifest.xml
Reply:
Above the original LISTVIEW when put directly on the Main Activity, (main activity extends activity)
listView.setOnScrollListener (mScrollListener);
OnScrollListener mScrollListener = new OnScrollListener () {

@ Override
public void onScrollStateChanged (AbsListView view, int scrollState) {
switch (scrollState) {
case OnScrollListener.SCROLL_STATE_FLING:
adapter.setFlagBusy (true);
break;
case OnScrollListener.SCROLL_STATE_IDLE:
adapter.setFlagBusy (false);
break;
case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL:
adapter.setFlagBusy (false);
break;
default:
break;
}
adapter.notifyDataSetChanged ();
}
@ Override
public void onScroll (AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {

}
};
scrolllistener can perform, listview in detail can be scrolled.
But the listview move fragment, main activity extends activity becomes the main activity extends FragmentActivity
listView.setOnScrollListener (mScrollListener);
Also can not perform, nor error.
Reply:
Or call onCreateView in onCreate called in /
Reply:
onCreateView

public View onCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
Log.v ("MyFragment1", "OnCreateView .......");
View v = inflater.inflate (R.layout.activity_tab_fragment1, container, false);
listView = (ListView) v.findViewById (R.id.listView1);
adapter = new LoaderAdapter (10, v.getContext (), R.layout.activity_ent001000_list_item, URLS);
listView.setAdapter (adapter);
listView.setOnScrollListener (mScrollListener);
listView.setClickable (true);
listView.setOnItemClickListener (mItemClickListener);
return v;

}
Reply:
Will the getItem method and adapter on ah
corresponding listviewpublic Object getItem (int position) {
return position;
}
In this method, set breakpoints can not walk in.
Reply:
The reason seems to be found in the fragment to use nested getChildFragmentManager () this method, but I now android-support-v13.jar added to the project or compile, but after that there is no method.

utf8 garbled how normal display


I have a database db file, the data table has a field is kept garbled.
Now been measured before, this field is utf8 encoded.
I took this field from the database, how it is displayed as normal characters?
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Database already exists, and now want to use this database file. Internet is a lot, did not find specific solutions, find great God Weapon!
Reply:
Access to data is garbled by UTF8 encoding it?
Reply:
Can not be resolved, Bengxiang unless there sqlite inside, otherwise you have to send json
Reply:
reference to the second floor jack_wolf_ reply:
by UTF8 encoded data is garbled to get it?

Ah using new String (paramString.getBytes (), "utf-8") This method is garbled, and get stored in the database is the same
Reply:
reference to the third floor heaimnmn reply:
not resolved, will not catch up, unless there is a sqlite inside, otherwise you have to send json

. . .
Reply:
Determine the database encoding is UTF8? If so, whether it may be time to write the ASCII code to write data? Treat it as ASCII code data taken out look.

The best way is to talk to write data to confirm what is written specifically coded data.
Reply:
Database encoding is UTF8, however, encoding the data stored inside, is not necessarily UTF8,,, there are some confused people will scrawl, but as he read his own way out of the normal.
Reply:
Positive solutions ...

reference to the 6th floor hslinux reply:
determine the database encoding is UTF8 and if so, whether it might be time to write the ASCII code to write data?? Treat it as ASCII code data taken out look.

The best way is to talk to write data to confirm what is written specifically coded data.

Reply:
reference to the 6th floor hslinux reply:
determine the database encoding is UTF8 and if so, whether it might be time to write the ASCII code to write data?? Treat it as ASCII code data taken out look.

The best way is to talk to write data to confirm what is written specifically coded data.


I try
Reply:
I suspect that the field is made up encryption algorithms. . . I do not know the rules can not be restored. .
The database is looking for online. . .
Reply:
reference to the third floor heaimnmn reply:
not resolved, will not catch up, unless there is a sqlite inside, otherwise you have to send json

How to get existence sqlite inside?

Making incremental OTA upgrade package fails


Consult android 4.2 OTA upgrade incremental package produced under question:
Use the command is not executed directly. / Builed / tools / releasetools / ota_from_target_file-i target.zip source.zip output.zip
Tips following error message:
: The file name is too long
import: unable to open X server `'@ import.c/ImportImageCommand/361
.-Bash: build / tools / releasetools / ota_from_target_files: line 61: syntax error
appear in unexpected "1" in the vicinity-Bash: build / tools / releasetools / ota_from_target_files: line 61: `sys.exit (1) '

What is the reason, how to solve, thank you very much!
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
I remember like execution make otapackage in android directory on
Reply:
make otapackage can be executed successfully, but make otapackage is prepared to upgrade the whole package, and now I want to check the programmed incremental subcontracting.
Reply:
Private letter your last question this issue: ValueError: can't find recovery API version in input target-files
Is encountered before, then checked the records at the time of modification, there is no record, but fortunately also records the error content. Now carefully looked at, the memories came out I was wrong, and re-recorded here, and you can have a look you have not committed such an error: ValueError: can't find recovery API version in input target-files
Also know the reason was not recorded, and make mistakes too low level. :)
After the error, no matter how low should be properly recorded, because the brain is cyclical, over a period of time will be forgotten.

How did the ball movement


I want to draw a small ball movement on the screen, the results did not respond
 
package com.example.systemaction;

import android.R.integer;
import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.AttributeSet;
import android.view.View;

public class BallActivity extends Activity {

@ Override
public void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
MyView v = new MyView (this, null);
setContentView (v);
}

class MyView extends View implements Runnable {

private int cx = 20, cy = 20;

public MyView (Context context, AttributeSet attrs) {
super (context, attrs);
setFocusable (true);
. new Thread (this) start ();
}

@ Override
public void run () {
Looper.prepare ();
ReFreshHandle handler = new ReFreshHandle ();
while (! Thread.currentThread (). isInterrupted ()) {
/ / Send the message to update the interface
Message message = new Message ();
message.what = 0x101;
handler.sendMessage (message);
try {
Thread.sleep (100);
} Catch (InterruptedException i)
{
i.printStackTrace ();
}
}
Looper.loop ();
}

/ / Draw a small ball
@ Override
protected void onDraw (Canvas canvas) {
super.onDraw (canvas);
Paint paint = new Paint ();
paint.setColor (Color.GREEN);
canvas.drawCircle (cx, cy, 10, paint);
}

/ / Update interface processor
class ReFreshHandle extends Handler {

@ Override
public void handleMessage (Message msg) {
if (msg.what == 0x101) {
MyView.this.update ();
MyView.this.invalidate ();
}
super.handleMessage (msg);
}
}

/ / Update the coordinates of ball movement
public void update () {
int h = getHeight ();
cy + = 5;
if (cy> = h) {
cy = 20;
}

}
}
}
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
You print your thread under the look did not start.
Reply:
The ReFreshHandle handler = new ReFreshHandle ();
Put out, do not put run in

Reply:
reference to the second floor hjywyj reply:
will ReFreshHandle handler = new ReFreshHandle ();
Put out, do not run into the inside
ah, I really was not careful, thank you

Tuesday, April 29, 2014

Import cocos2d-x with Eclipse Android engineering problems


cocos2d-x 3.0beta2, guide Ruan Zhuo works appear
Unable to resolve target 'android-10' errors.

However proj.android \ project.properties file inside target.
target = android-16

,
Is consistent with the api leveal.
Then you can still packaged into APK, but run on the error. "Unfortunately, XXX run error"
Andrews did not study and development, has been stuck here, please predecessors taught me!
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->

ListView drop-down problem


listview default can not be pulled down. On some phones can be pulled down. Figure:


There are currently found in some models that can be pulled down seeking solutions.

Currently listview have tried all the basic attributes, there listview height wrote dead useless,
If you want to point to rewrite listview ideas, thank you. How could you ban pulldown.
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Nobody Mody. . Variety. .
Reply:
Can be pulled down, ah, why not drop down it? You are not setting can not be pulled down the
Reply:
The landlord says you can not be pulled down what ah mean?
ListView itself can not be pulled down, how you can.
Or say you do not want to be dragged down the overall make ListView? If so, you will not change, this root has a relationship models
Reply:
Not prohibited, it is a custom manufacturer - in fact, imitation ios
Reply:
Landlord. . . I encountered the same problem with you, I was able to pull down tests found listview, how can not be cut off, to rewrite it, and test models are coolpad Meizu, version 2.3 is on the low version, the landlord to solve the problem Why? ? ? ?

ViewPager can not be displayed


ViewPager FragmentActivity sub Fragment included in FragmentTabHost not display expert answers to solve

Download address http://pan.baidu.com/s/1c0vMr3i
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Their top nobody get over it
Reply:
Paste the code on the map to get hold of people to download something to help you test? Anyway, I will not do
Reply:
Your layout problems

fragment_1.xml
 xmlns: tools = "http://schemas.android.com/tools" 
android: layout_width = "fill_parent"
android: layout_height = "fill_parent"
android: orientation = "vertical">

android: id = "@ + id / main_title"
android: layout_width = "fill_parent"
android: layout_height = "wrap_content"
layout = "@ layout / tilte" />

android: id = "@ + id / main_view_pager"
android: layout_width = "fill_parent"
android: layout_height = "fill_parent"
android: layout_gravity = "center"
android: flipInterval = "30"
android: persistentDrawingCache = "animation" />



Reply:
reference to the third floor hjywyj reply:
your layout problems

fragment_1.xml
 xmlns: tools = "http://schemas.android.com/tools" 
android: layout_width = "fill_parent"
android: layout_height = "fill_parent"
android: orientation = "vertical">

android: id = "@ + id / main_title"
android: layout_width = "fill_parent"
android: layout_height = "wrap_content"
layout = "@ layout / tilte" />

android: id = "@ + id / main_view_pager"
android: layout_width = "fill_parent"
android: layout_height = "fill_parent"
android: layout_gravity = "center"
android: flipInterval = "30"
android: persistentDrawingCache = "animation" />


where the problem can be said about it?
Reply:
reference to the third floor hjywyj reply:
your layout problems

fragment_1.xml
 xmlns: tools = "http://schemas.android.com/tools" 
android: layout_width = "fill_parent"
android: layout_height = "fill_parent"
android: orientation = "vertical">

android: id = "@ + id / main_title"
android: layout_width = "fill_parent"
android: layout_height = "wrap_content"
layout = "@ layout / tilte" />

android: id = "@ + id / main_view_pager"
android: layout_width = "fill_parent"
android: layout_height = "fill_parent"
android: layout_gravity = "center"
android: flipInterval = "30"
android: persistentDrawingCache = "animation" />


Thank you discovered the problem
Reply:
reference to the second floor Lee_shuo reply: posted code shown on
people get hold of something to help you download the test? Anyway, I will not do

I think so, I think that the main floor is the key code to learn, learn to paste the key code. .