I have a form with 6 buttons on it, and I am currently trying to get the 3rd to work. The first two buttons work correctly but when I click on the third button, nothing at all happens, and I get no errors. Can anyone help?
I have checked the form names, class names and button names but I can't get it to work. I have included the code for the buttons.
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setting fullscreen
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN );
setContentView(R.layout.main_menu);
initialize(); //calling this method
}
public void initialize(){
//Initializing variables
Film = (Button) findViewById(R.id.bFilm);
Music = (Button) findViewById(R.id.bMusic);
Poets = (Button) findViewById(R.id.bPoet);
Inventors = (Button) findViewById(R.id.bInventors);
Science = (Button) findViewById(R.id.bScience);
Sports = (Button) findViewById(R.id.bSport);
//initialzing onclicklisteners
Film.setOnClickListener(this);
Music.setOnClickListener(this);
Sports.setOnClickListener(this);
}
#Override
public void onClick(View view) {
//case statment for onclicklisteners
try{
switch(view.getId()){
case R.id.bFilm:
Intent film = new Intent(this, Film.class); //open film class
startActivity(film);
break;
case R.id.bMusic:
Intent music = new Intent(this, Music.class); //open music class
startActivity(music);
break;
case R.id.bPoet:
Intent poet = new Intent(this, Poets.class); //open poet class
startActivity(poet);
break;
case R.id.bInventors:
Intent invent = new Intent(this, Inventors.class); //open inventors class
startActivity(invent);
break;
case R.id.bScience:
Intent science = new Intent(this, Science.class); // open science class
startActivity(science);
break;
case R.id.bSport:
Intent sport = new Intent(this, Sports.class); //open sports class
startActivity(sport);
break;
}
If Sports is your 3rd button
Make sure you dont have any element in your xml with the id bSport expect the bSport button itself.
Remove the try{} catch(){}. and see if your app crash, and make sure you have added Sports activity to the Manifest
You have only set click listeners for 3 buttons (Film, Music, and Sports), you have to set all the listeners in your initlialize.
enter code here
public void initialize(){
//Initializing variables
Film = (Button) findViewById(R.id.bFilm);
Music = (Button) findViewById(R.id.bMusic);
Poets = (Button) findViewById(R.id.bPoet);
Inventors = (Button) findViewById(R.id.bInventors);
Science = (Button) findViewById(R.id.bScience);
Sports = (Button) findViewById(R.id.bSport);
//initialzing onclicklisteners
Film.setOnClickListener(this);
Music.setOnClickListener(this);
Sports.setOnClickListener(this);
Poets.setOnClickListener(this);
Inventors.setOnClickListener(this);
Science.setOnClickListener(this);
}
Related
I'm trying to make some layouts and listviews gone and visible by pressing a button located in another activity.
Also I want to input some text in an edittext located in the same activity as the layouts
I've looked all over this place and I found several examples but I just couldn't make them work so I'm posting my own code.
btnnext1.setOnClickListener(new OnClickListener() {
val next1 = Intent(this, next1::class.java)
startActivity(next1)
categories.visibility = View.GONE
listacats.visibility = View.VISIBLE
ListView.visibility = View.VISIBLE
e_search.setText("blackcat")
})
From what I found out this can be achieved by using intent.PutExtra, but I just couldn't make it work.
Thank you in advance for your support
The main task is pass "blackcat" to another activity, you could do like this:
In MainActivity:
final Button button = findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this,OtherActivity.class);
intent.putExtra("passed_str", "blackcat");
startActivity(intent);
}
});
In OtherActivity:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_other);
String receivedStr = getIntent().getStringExtra("passed_str");//receive string
final EditText editText = (EditText) findViewById(R.id.editText);
editText.setText(receivedStr);
categories.setVisibility(View.GONE); //change wiget's visibility
listacats.setVisibility(View.INVISIBLE);
ListView.setVisibility(View.INVISIBLE);
}
In my main activity, I have 6 checkboxes for selecting which parts of a test the person will want to take. I've looked at a bunch of pages trying to figure out what to do, but I couldn't gain a clear understanding of what I was supposed to do.
Let's say, in my main activity, I have the checkboxes:
CheckBox grade1 = (CheckBox)findViewById(R.id.grade1);
CheckBox grade2 = (CheckBox)findViewById(R.id.grade2);
CheckBox grade3 = (CheckBox)findViewById(R.id.grade3);
CheckBox grade4 = (CheckBox)findViewById(R.id.grade4);
CheckBox grade5 = (CheckBox)findViewById(R.id.grade5);
CheckBox grade6 = (CheckBox)findViewById(R.id.grade6);
And if they're checked, I want to pass them to my next activity using this onClick (with whatever code needs to be added to make it work):
private void setupMessageButton() {
Button messageButton = (Button) findViewById(R.id.main_button);
messageButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
startActivity(new Intent(MainActivity.this, Test.class));
}
});
}
Then in my new activity, I have if statements which are currently written this way:
if (grade1.isChecked()){
// Do stuff
}
I'm looking for the simplest way to do this. TL:DR - If a checkbox is checked in one activity, how can I use that status to do something in another activity with an if statement?
Using the answer from poss, I was able to figure this out. I have 6 checkboxes in my main activity in the onClick.
CheckBox grade1 = (CheckBox)findViewById(R.id.grade1);
CheckBox grade2 = (CheckBox)findViewById(R.id.grade2);
CheckBox grade3 = (CheckBox)findViewById(R.id.grade3);
CheckBox grade4 = (CheckBox)findViewById(R.id.grade4);
CheckBox grade5 = (CheckBox)findViewById(R.id.grade5);
CheckBox grade6 = (CheckBox)findViewById(R.id.grade6);
So I just need to pass them using the following code (also in the onClick):
Intent intent = new Intent(MainActivity.this, Test.class);
intent.putExtra("grade1", grade1.isChecked());
intent.putExtra("grade2", grade2.isChecked());
intent.putExtra("grade3", grade3.isChecked());
intent.putExtra("grade4", grade4.isChecked());
intent.putExtra("grade5", grade5.isChecked());
intent.putExtra("grade6", grade6.isChecked());
startActivity(intent);
Then in my second activity, just like poss stated, these need to be at the top:
Boolean check1 = getIntent().getExtras().getBoolean("grade1");
Boolean check2 = getIntent().getExtras().getBoolean("grade2");
Boolean check3 = getIntent().getExtras().getBoolean("grade3");
Boolean check4 = getIntent().getExtras().getBoolean("grade4");
Boolean check5 = getIntent().getExtras().getBoolean("grade5");
Boolean check6 = getIntent().getExtras().getBoolean("grade6");
And for my if statements, I just do:
if (check1){
// Do stuff
}
if (check2){
// Do more stuff
}
if (check2){
// Etc...
}
Thanks for the help in solving this!!
You can use intent.
In your MainActivity.java:
private void setupMessageButton() {
Button messageButton = (Button) findViewById(R.id.main_button);
messageButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, Test.class);
intent.putExtra("selectedGrade", v.getId());
startActivity(intent);
}
}
In your Test.java:
int selectedGrade = getIntent().getExtras().getint("selectedGrade");
switch (selectedGrade) {
case R.id.grade1: //do something
break;
case R.id.grade2: //do something
break;
....
}
You can use Intent extras for this.
For example, if checkBox 1 is checked, you can put extra into intent like this.
Intent intent = new Intent(MainActivity.this, Test.class);
intent.putExtra("check1", true);
startActivity(intent);
In your Test.class you just retrieve the value.
Boolean check1 = getIntent().getExtras().getBoolean("check1");
Below is what i have tried. "Forward" class extends Activity. It contains two buttons. In this class , we create two objects of "Collector" class using for loop. In the first iteration of the loop we create first button. In the second, we create one more button. we set "OnClickListener" for both the buttons. but only the second button responds for the click. First button doesnt respond to a click. I'm trying to use same variable name (b1) - I want to stick to OO Principle by not creating separate object for achieving my goal. - Also I'm expecting properties of 2 Objects as separate entity.Please help me. regards.
Forward.java (is an Activity, contains two buttons):
below is a for loop in which i create 2 objects of collector class.
for (int i = 0; i < 2; i++) {
new Collector(this, i);
}
Collector.java :
public class Collector {
Forwarder f;
int n;
Button b1;
public Collector(Forwarder caller, int i) {
f = caller;
n = i; // 0 or 1
f.setContentView(R.layout.forwarder);
switch(n)
{
case 0:
b1 = (Button) f.findViewById(R.id.button1);
b1.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
// get a new Contact
Intent i = new Intent(Intent.ACTION_PICK,
ContactsContract.Contacts.CONTENT_URI);
f.startActivityForResult(i, 1);
// onActivityResult has to be implemented in f because
// f extends Activity class
}
});
break;
case 1:
b1 = (Button) f.findViewById(R.id.button2);
b1.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
// get a new Contact
Intent i = new Intent(Intent.ACTION_PICK,
ContactsContract.Contacts.CONTENT_URI);
f.startActivityForResult(i, 1);
}
});
break;
default:
}
}
}
You gave Your button a new id.
first, You wrote:
b1 = (Button) f.findViewById(R.id.button1);
at the second switch You wrote:
b1 = (Button) f.findViewById(R.id.button2);
public class Collector {
Forwarder f;
int n;
Button b1;
public Collector(Forwarder caller, int i) {
f = caller;
n = i; // 0 or 1
f.setContentView(R.layout.forwarder);
switch(n)
{
case 0:
b1 = (Button) f.findViewById(R.id.button1);
b1.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
// get a new Contact
Intent i = new Intent(Intent.ACTION_PICK,
ContactsContract.Contacts.CONTENT_URI);
f.startActivityForResult(i, 1);
// onActivityResult has to be implemented in f because
// f extends Activity class
}
});
break;
case 1:
b1 = (Button) f.findViewById(R.id.button1);
b1.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
// get a new Contact
Intent i = new Intent(Intent.ACTION_PICK,
ContactsContract.Contacts.CONTENT_URI);
f.startActivityForResult(i, 1);
}
});
break;
default:
}
}
}
You have mistaken in your switch case you named both of buttons b1 when the second object starts to be create b1 is no longer Button1 now it is Button2 so you set onclick listener only for Button2 use a custom class for your buttons or try to declear new objects like b2 b3
good luck soheil
Check the button names. They are the same (b1). Change the second variable name and everything should work perfectly. Damn copy-paste :P
I don't have the answer on why such behavior but it will definitively help you if you add few things as a part of clarification or rephrase your question else people consider it as some novice mistake.
- Clearly mention that you know that you are trying to use same variable name (b1)
- You want to stick to OO Principle by not creating separate object for achieving your goal.
- Also you can mention that you are expecting properties of 2 Objects as separate entity.
Hope it helps. All the best.
I want to know how I can obtain the value of a button and then use it on another activity to display content accordingly.
Example:
I have 3 buttons Image1, Image2 & Image3 on my MainActivity.
Now based on what button the user clicks (Image1, Image2 & Image3), a corresponding image is displayed on a new activity.
I know how to create these buttons, the new activity and also how to display an image on the new activity. How do I display the image based on what button the user clicks?
Your class should implement OnClickListener and override onClick()
Button button1 = (Button) findViewById(R.id.button1);
Button button2 = (Button) findViewById(R.id.button2);
Button button3 = (Button) findViewById(R.id.button3);
button1.setOnClickListener(new OnClickListener(this));
button2.setOnClickListener(new OnClickListener(this));
button3.setOnClickListener(new OnClickListener(this));
#Override
public void onClick(View v){
switch(v.getId()) //get the id which is an int
{
case R.id.button1 : //if its button1 that is clicked
Intent i= new Intent("com.example.secondActivity");
i.puExtra("key",value);
startActivity(i);
// use intents to pass information to secondActivity and display the image there
break;
case R.id.button2 :
Intent i= new Intent("com.example.secondActivity");
startActivity(i)
//use intents to pass information to secondActivity and display the image there
break;
case R.id.button3 :
Intent i= new Intent("com.example.secondActivityy");
startActivity(i)
//use intents to pass information to secondActivity and display the image there
break;
}
}
To pass values using intents
On Button click
Intent i= new Intent("com.example.secondActivity");
i.puExtra("key",value);
startActivity(i);
In Second Activity retrieve it as below
Bundle extras = getIntent().getExtras();
if(extras!=null)
{
int values= extras.getInt("key");
}
Why not use a switch case to determine which button was clicked by the user and show the corresponding / relevant image in the next activity? For example:
First, make your Activity implement the OnClickListener. Then, in the onCreate() cast your Buttons and set their setOnClickListener
#Override
public void onCreate(Bundle savedInstanceState) {
....
Button Image1 = (Button) findViewById(R.id.Image1);
Image1.setOnClickListener(this);
.... // THE REST OF THE BUTTONS
}
I am assuming you are passing a Bundle in the Intent for starting the next Activity. Change that code to pass information that contains which button was pressed.
For example:
Intent showPhoto = new Intent(CurrentActivity.this, YOUR_SECOND_ACTIVITY.class);
showPhoto.putExtra("BUTTON_CLICKED", "IMAGE1");
startActivity(showPhoto);
#Override
public void onClick(View v) {
// Perform action on click
switch(v.getId()) {
case R.id.Image1:
// RUN THE CODE TO START THE NEXT ACTIVITY
Intent showPhoto = new Intent(CurrentActivity.this, YOUR_SECOND_ACTIVITY.class);
showPhoto.putExtra("BUTTON_CLICKED", "IMAGE1");
startActivity(showPhoto);
break;
case R.id.Image2:
// RUN THE CODE TO START THE NEXT ACTIVITY
Intent showPhoto = new Intent(CurrentActivity.this, YOUR_SECOND_ACTIVITY.class);
showPhoto.putExtra("BUTTON_CLICKED", "IMAGE2");
startActivity(showPhoto);
break;
case R.id.Image3:
// RUN THE CODE TO START THE NEXT ACTIVITY
Intent showPhoto = new Intent(CurrentActivity.this, YOUR_SECOND_ACTIVITY.class);
showPhoto.putExtra("BUTTON_CLICKED", "IMAGE3");
startActivity(showPhoto);
break;
}
}
}
I have 3 buttons Image1, Image2 & Image3 on my MainActivity. Now based
on what button the user clicks (Image1, Image2 & Image3), a
corresponding image is displayed on a new activity.
=> As you already said yo know how to create buttons and initiate it.
Now you just need to assign OnClickListener to every buttons and then pass Image id or URL into the Intent by which you are calling new activity.
Check the code posted by #IceMAN above, now as I mentioned above, put ImageURL or Image ID into Intent by using putExtra() method.
For example:
Intent intent= new Intent(CurrentClass.this, ImageActivity.class);
intent.putExtra("ImageURL",strImageURL);
startActivity(i);
For example you have 3 Buttons and ImageView in Main layout:
Main.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ll_main"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<Button
android:layout_width="100dp"
android:layout_height="50dp"
android:id="#+id/btn1"
android:text="button 1"
/>
<Button
android:layout_width="100dp"
android:layout_height="50dp"
android:id="#+id/btn2"
android:text="button 2"
/>
<Button
android:layout_width="100dp"
android:layout_height="50dp"
android:id="#+id/btn3"
android:text="button 3"
/>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:id="#+id/iv"
/>
I your activity metod onClick handle events from three buttons. And we need to recognize that the button has been pressed.
MyActivity.java
public class MyActivity extends Activity implements View.OnClickListener {
Button btn1;
Button btn2;
Button btn3;
ImageView iv;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
btn1 = (Button) findViewById(R.id.btn1);
btn2 = (Button) findViewById(R.id.btn1);
btn3 = (Button) findViewById(R.id.btn1);
iv = (ImageView) findViewById(R.id.iv);
btn1.setOnClickListener(this);
btn2.setOnClickListener(this);
btn2.setOnClickListener(this);
}
#Override
public void onClick(View v) {
switch (v.getId()){
case R.id.btn1:
{
Toast toast = Toast.makeText(this, "onClickButton1", Toast.LENGTH_SHORT);
toast.show();
iv.setImageDrawable(R.drawable.my_image_1);
break;
}
case R.id.btn2:
{
Toast toast = Toast.makeText(this, "onClickButton2", Toast.LENGTH_SHORT);
toast.show();
iv.setImageDrawable(R.drawable.my_image_2);
break;
}
case R.id.btn3:
{
Toast toast = Toast.makeText(this, "onClickButton3", Toast.LENGTH_SHORT);
toast.show();
iv.setImageDrawable(R.drawable.my_image_3);
break;
}
}
}
}
Where my_image_1, my_image_2, my_image_3 - images, from your Drawable folder.
Hope its Help.
Add this in onCreate of your activity that contains the 3 buttons
Button image1 = (Button) findViewById(R.id.image1);
image1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
startActivity(new Intent(getApplicationContext(), DisplayImagActivity.class)
.putExtra("ImageName", "Image1"));
}
});
Button image2 = (Button) findViewById(R.id.image2);
image2.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
startActivity(new Intent(getApplicationContext(), DisplayImagActivity.class)
.putExtra("ImageName", "Image2"));
}
});
Button image3 = (Button) findViewById(R.id.image3);
image3.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
startActivity(new Intent(getApplicationContext(), DisplayImagActivity.class)
.putExtra("ImageName", "Image3"));
}
});
Add this in onCreate of your activity where you will set the image:
String imageName = getIntent().getStringExtra("ImageName");
if(imageName.equals("Image1")) {
//set image 1
}
else if(imageName.equals("Image2")) {
//set image 2
}
else if(imageName.equals("Image3")) {
//set image 3
}
You simply implement one ClickListener for each button, which will start the corresponding activity. See an example here.
I know this is and old question, but there is another way, which I prefer, because you can use the same default method for all buttons.
First add a tag to each button.
<Button
android:id="#+id/imageOneButton"
android:tag="1"
android:onClick="chooseImage" />
Then use this tag number to alter the behavior of your method.
public void chooseImage(View view) {
int imageNumber = Integer.parseInt(view.getTag().toString());
// I'll just send this tag number to a toast, but you can send it in your intent
// as an "Extra"
Toast.makeText(this, view.getTag().toString(), Toast.LENGTH_SHORT).show();
}
I am tyring to figure out how to make an app that lets the users of the app post items for sale with pictures where other users that search it can view those items. For example something like craigslist for android. I want to set up an app where users can fill in edit texts like Category, Title, Price, Description and a Picture of the item they want to post for sale. How can I achieve this so users can search for items as well. From what I understand I have to take what a user is inputting for sale and send to a server so others can search it, right? Can anyone direct in a direction to get started, this is what I have for a user to post an item:
public class Post extends Activity implements OnClickListener {
ImageButton ibutton1;
ImageButton ibutton2;
ImageButton ibutton3;
ImageButton ibutton4;
ImageButton ibutton5;
ImageButton ibutton6;
Intent i1;
Intent i2;
Intent i3;
Intent i4;
Intent i5;
Intent i6;
final static int cameraData1 = 1;
final static int cameraData2 = 2;
final static int cameraData3 = 3;
final static int cameraData4 = 4;
final static int cameraData5 = 5;
final static int cameraData6 = 6;
Bitmap bmp;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.post);
Button button = (Button) findViewById(R.id.bNext);
button.setOnClickListener(mNextListener);
// Category spinner set up
Spinner cSpinner = (Spinner) findViewById(R.id.spCategoryPost);
ArrayAdapter<CharSequence> adapter2 = ArrayAdapter.createFromResource(
this, R.array.category_array,
android.R.layout.simple_spinner_item);
adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
cSpinner.setAdapter(adapter2);
cSpinner.setOnItemSelectedListener(new MyOnItemSelectedListener2());
initialize();
}
private void initialize() {
ibutton1 = (ImageButton) findViewById(R.id.imageButton1);
ibutton2 = (ImageButton) findViewById(R.id.imageButton2);
ibutton3 = (ImageButton) findViewById(R.id.imageButton3);
ibutton4 = (ImageButton) findViewById(R.id.imageButton4);
ibutton5 = (ImageButton) findViewById(R.id.imageButton5);
ibutton6 = (ImageButton) findViewById(R.id.imageButton6);
ibutton1.setOnClickListener(this);
ibutton2.setOnClickListener(this);
ibutton3.setOnClickListener(this);
ibutton4.setOnClickListener(this);
ibutton5.setOnClickListener(this);
ibutton6.setOnClickListener(this);
}
public void onClick(View Images) {
switch (Images.getId()) {
case R.id.imageButton1:
i1 = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i1, cameraData1);
break;
case R.id.imageButton2:
i2 = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i2, cameraData2);
break;
case R.id.imageButton3:
i3 = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i3, cameraData3);
break;
case R.id.imageButton4:
i4 = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i4, cameraData4);
break;
case R.id.imageButton5:
i5 = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i5, cameraData5);
break;
case R.id.imageButton6:
i6 = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i6, cameraData6);
break;
}
}
private OnClickListener mNextListener = new OnClickListener() {
public void onClick(View v) {
EditText edit = (EditText) findViewById(R.id.etTitle);
EditText editP = (EditText) findViewById(R.id.etPrice);
EditText editD = (EditText) findViewById(R.id.etDescription);
long currentTime = System.currentTimeMillis();
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(currentTime);
String showTime=String.format("%1$tI:%1$tM:%1$tS %1$Tp",cal);
Intent intent = new Intent(Post.this, PostSet.class);
intent.putExtra("com.mandam.isellibuy.TITLE", edit.getText().toString());
intent.putExtra("com.mandam.isellibuy.PRICE", editP.getText().toString());
intent.putExtra("com.mandam.isellibuy.DESC", editD.getText().toString());
intent.putExtra("currentTime", currentTime);
startActivity(intent);
}
};
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK){
Bundle extras = data.getExtras();
bmp = (Bitmap) extras.get("data");
ibutton1.setImageBitmap(bmp);
}
}
}
Now I take the value of all these edit texts, spinner, and images and return it to another activity where the user can view all of this to make sure it looks good and post the item for sale, here is the activity:
public class PostSet extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.post_set);
// Setting text of edit text tvTitle from class Post
TextView tv1 = (TextView) findViewById (R.id.tvTitleText);
TextView tv2 = (TextView) findViewById (R.id.tvPrice);
TextView tv3 = (TextView) findViewById (R.id.tvTimeStamp);
TextView tv4 = (TextView) findViewById (R.id.tvDescription);
Intent intent = getIntent();
String edit = intent.getStringExtra("com.mandam.isellibuy.TITLE");
String editP = intent.getStringExtra("com.mandam.isellibuy.PRICE");
String editD = intent.getStringExtra("com.mandam.isellibuy.DESC");
//long currentTime = extras.getLong("currentTime");
tv1.setText(edit);
tv2.setText(editP);
tv4.setText(editD);
//tv3.setText(currentTime);
}
}
Now this Activity just displays all the input from the user to look it over and there is a button "Submit" that the user clicks to submit the item for sale so others can view the item on my app. This is where I get confused how do I achieve that?
So the answer to your question in the title "does Android have a server..." is no. There's no server that Google provides specifically for Android. However, Android can do standard network communication--you can use any accessible server of your choice. There are plenty of free (tiered) servers including Google App Engine, Heroku and AWS. You'll have to create your own server-side component though.
You're probably getting downvotes because the actual body of your question is extremely broad. I could probably reword your question as "How can I create Craigslist but for Android?". There's a lot involved and there are a huge range of possibilities and differing requirements. You need to break down your problem into pieces, fill in what you can and then if you have any specific technical questions about pieces of that, then ask those here on StackOverflow.
I will try to help you get started in the right direction as you asked though, you should take a look at learning how to implement a web service, then create one to post your listings to and to retrieve listings. In that web service you'll have to interpret the request, and most likely save the data into a database. Likewise when retrieving listings, you'll have to go to the database to retrieve previously stored listings, potentially filter/sort them and then return them in some form back.
This is not a trivial task, good luck.