|
Who can help me in customize that
please tell me site or forum
i will try to ask him
|
|
|
|
|
|
Are you a developer?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Yes but im beginner for development in android
|
|
|
|
|
But creating, or using, a container (i.e., data structure) to hold data that you download from a JSON file has nothing to do with Android.
If the code you've shown is entirely of your making, then you shouldn't be having trouble.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
I modify my code above as following
I storage the parsed ArrayList, make a global variable for counting the number of times that the button has been clicked.
public class MainActivity extends ListActivity {
ArrayList<foursquarevenue> venuesList;
Button btn;
int clickCount;
// ArrayList<foursquarevenue> allResults;
List<string> shownResults = new ArrayList<string>();
final String CLIENT_ID = "SVIBXYYXOEARXHDI4FWAHXGO5ZXOY204TCF1QJFXQLY5FPV4";
final String CLIENT_SECRET = "BAAJO1KXRWESGTJJGVON4W3WUFHAQDAJPLRIYJJ5OPHFQ5VI";
final String latitude = "30.435665153239377";
final String longtitude = "31.3280148";
ArrayAdapter <string> myAdapter;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new fourquare().execute();
btn=(Button) findViewById(R.id.button);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v)
{
String name = venuesList.get(clickCount).getName();
String cat = venuesList.get(clickCount).getCategory();
String city = venuesList.get(clickCount).getCity();
shownResults.add(name + "," + "cat" + "" + city);
clickCount++;
myAdapter.notifyDataSetChanged();
new fourquare().execute();
}
});
}
what is wrong in my code
|
|
|
|
|
ahmed_sa wrote:
what is wrong in my code I don't know, you tell us. What's it (not) doing? What's is (not) supposed to do? Is an exception being thrown? I obviously can't know these things.
I do know you don't need to call notifyDataSetChanged() since neither the array nor the adapter are changing in the onClick() method.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Why my android is not connecting with the
mobile phone..???
when m run my programme it dont show
in the cell phone
|
|
|
|
|
Could be any of a hundred different reasons. Good luck.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
HI all.I am new beginer to android.I Want to write an android app.
WHat do I Need now.I Have read some books but may be it is out of date so I ask here.
First I need to install Java JDK to my PC.
Second I need Android Studio.
Is that all now???
THanks.
|
|
|
|
|
hmanhha wrote:
First I need to install Java JDK to my PC.
Second I need Android Studio. Both of which can be done from here.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
|
Yes.After installing android studio, you need to install the required sdk pacakages for which version you want your android app to run.
|
|
|
|
|
Hi
I make one app have only one activity is main activity and it have
button
textview
linear layout
the json file i connect to it is
public static String URL_GET_Place = "https://api.foursquare.com/v2/venues/search?client_id=SVIBXYYXOEARXHDI4FWAHXGO5ZXOY204TCF1QJFXQLY5FPV4&client_secret=BAAJO1KXRWESGTJJGVON4W3WUFHAQDAJPLRIYJJ5OPHFQ5VI&v=20130815&ll=30.1136286,31.3280148&query=resturant";
what i need is get all items from this file item by item
based on three atributes and every click get next item
name,id,location
when i press the fab button to first time get first item
when i press the fab button to second time get second item
when i press the fab button to third time get third item
when i press the fab button to four time get four item
until i get all items in json file based on three attributs id,name,location
How i make that by code if possible help me
|
|
|
|
|
ahmed_sa wrote: How i make that by code if possible help me Exactly what do you need help with, processing the file, responding to button clicks, populating a listview? What code have you put together so far? What is it (not) doing?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
 My code is
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_eating);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
card1 = (LinearLayout) findViewById(R.id.card_one);
card2 = (LinearLayout) findViewById(R.id.card_two);
card3 = (LinearLayout) findViewById(R.id.card_three);
tvTitle1 = (TextView) findViewById(R.id.tv_title1);
tvTitle2 = (TextView) findViewById(R.id.tv_title2);
tvTitle3 = (TextView) findViewById(R.id.tv_title3);
tvDetails1 = (TextView) findViewById(R.id.tv_details1);
tvDetails2 = (TextView) findViewById(R.id.tv_details2);
tvDetails3 = (TextView) findViewById(R.id.tv_details3);
card1.setonclickListener(this);
card2.setonclickListener(this);
card3.setonclickListener(this);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setonclickListener(new View.onclickListener() {
@Override
public void onclick(View view) {
if (count < 3) {
new GetPlace().execute();
}
}
});
}
class GetPlace extends AsyncTask<Void, Void, Void> {
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(EatingActivity.this);
pDialog.setMessage("Picking an Item...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
}
protected Void doInBackground(Void... args) {
try {
List<NameValuePair> dataList = new ArrayList<NameValuePair>();
JSONObject json = jsonParser.
makeHttpRequest(AppConfig.URL_GET_Place, "GET", dataList);
JSONObject meta = json.getJSONObject("meta");
success = meta.getInt("code");
JSONObject response = json.getJSONObject("response");
JSONArray venues = response.getJSONArray("venues");
for (int i = 0; i < venues.length(); i++) {
selectedPlace = new Place();
JSONObject object = venues.getJSONObject(i);
selectedPlace.setTitle(object.getString("name"));
selectedPlace.setId(object.getString("id"));
JSONObject location = object.getJSONObject("location");
JSONArray formattedAddress=location.getJSONArray("formattedAddress");
Log.d("length",formattedAddress.length()+"");
String currentLocation="";
for (int j=0;j<formattedAddress.length();j++)
{
currentLocation+=formattedAddress.getString(j)+", ";
Log.d("address",currentLocation);
}
selectedPlace.setAddress(currentLocation);
selectedPlace.setLat(location.getDouble("lat"));
selectedPlace.setLng(location.getDouble("lng"));
Log.d("name", selectedPlace.getTitle());
places.add(selectedPlace);
}
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
protected void onPostExecute(Void args) {
if (!pDialog.isShowing()) {
pDialog.dismiss();
if (success == 200) {
if (count == 0) {
card1.setVisibility(View.VISIBLE);
tvTitle1.setText(places.get(count).getTitle());
tvDetails1.setText(places.get(count).getAddress());
} else if (count == 1) {
card2.setVisibility(View.VISIBLE);
tvTitle2.setText(places.get(count).getTitle());
tvDetails2.setText(places.get(count).getAddress());
} else if (count == 2) {
card3.setVisibility(View.VISIBLE);
tvTitle3.setText(places.get(count).getTitle());
tvDetails3.setText(places.get(count).getAddress());
}
count++;
} else {
Toast.makeText(EatingActivity.this, "Couldn't find any nearby places", Toast.LENGTH_LONG).show();
}
}
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home)
finish();
return super.onOptionsItemSelected(item);
}
@Override
public void onclick(View view) {
int index = 0;
if (view.getId() == card1.getId()) {
index = 0;
} else if (view.getId() == card2.getId()) {
index = 1;
} else if (view.getId() == card3.getId()) {
index = 2;
}
String strUri = "http://maps.google.com/maps?q=loc:"
+ places.get(index).getLat() + "," + places.get(index).getLng() +
"(" + places.get(index).getTitle() + ")";
Log.d("url",strUri);
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(strUri));
startActivity(intent);
}
}
|
|
|
|
|
What i need is when click fab button
on first time show first item
on second time click show second item
until it get all items in json file
meaning i need to customize code above
to show all items not three items but based on fab click
every click show item
|
|
|
|
|
That sounds like the wrong way to do it. Why not use a scrollable view (ListView or similar), populate it with all the items in the json data, and let the user scroll through it as necessary.
|
|
|
|
|
Thank you for reply
OK i will try with list view but
i need when click fab button retrieve me item by item
like scenario i will show
I will click fab button to first time it give me first item
when click fab to second time it give me second item
not show all item when press button
what i need actually press button get me item
when i press again give me next item until i get all items from json file
|
|
|
|
|
I'm not sure why you would want to do that, but I do not suppose it is too difficult. Just make sure that your reference to the JSON data is a class variable so you can access it from any method. You then just need to read the next record every time the button is pressed. Alternatively you could read all the data into some sort of List and use an index value to read each record in turn, and reset the index when you reach the last record.
|
|
|
|
|
I agree.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
ahmed_sa wrote: if (!pDialog.isShowing()) {
pDialog.dismiss(); This seems backward. Why would you dismiss a dialog that is not showing?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Thank you for reply
i will post my code full in another thread
and what i need to do
|
|
|
|
|
Hello all,
I have two layouts, one is below the other one. When user swipes down, I want upper layout to be bigger, and lower layout to be smaller and vice versa for when user swipes up. How can I achieve that?
Here is my layout :
="1.0"="utf-8"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
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"
tools:context="com.example.mydomain.myapplication1212.MainActivity">
<LinearLayout
android:id="@+id/above_element"
android:layout_width="match_parent"
android:layout_height="250dp"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/summ"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="250dp"
android:layout_below="@+id/above_element"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/flowers"/>
</LinearLayout>
</RelativeLayout>
|
|
|
|
|