Пожалуйста, помогите мне, я создал класс newReclamation
, в котором мы можем добавить название, название, должность, название и должность, с MapView
. Как я могу добавить MapView
и пометить свое положение вручную с помощью Marker
, а затем сохранить (Lang, Lat) в базе данных mysql.Добавить MapView в мою компанию
PS: теперь я сохраняю только название, тип и описание, и оно работает. Пожалуйста, помогите мне.
public class NewReclamationActivity extends Activity implements OnItemSelectedListener {
// Progress Dialog
private ProgressDialog pDialog;
private SQLiteHandler db;
JSONParser jsonParser = new JSONParser();
EditText inputName;
EditText inputDesc;
Spinner spinner;
// LogCat tag
private static final String TAG = NewReclamationActivity.class.getSimpleName();
// JSON Node names
private static final String TAG_SUCCESS = "success";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.add_reclamation);
spinner = (Spinner) findViewById(R.id.spinner);
spinner.setOnItemSelectedListener(this);
// Create an ArrayAdapter using the string array and a default spinner layout
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
R.array.type_array, android.R.layout.simple_spinner_item);
// Specify the layout to use when the list of choices appears
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// Apply the adapter to the spinner
spinner.setAdapter(adapter);
// Edit Text
inputName = (EditText) findViewById(R.id.inputName);
inputDesc = (EditText) findViewById(R.id.inputDesc);
// SqLite database handler
db = new SQLiteHandler(getApplicationContext());
// Create button
Button btnCreateReclamation = (Button) findViewById(R.id.btnCreateReclamation);
// button click event
btnCreateReclamation.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// creating new reclamation in background thread
new CreateNewReclamation().execute();
}
});
}
public void onItemSelected(AdapterView<?> parent, View view,
int pos, long id) {
// An item was selected. You can retrieve the selected item using
// parent.getItemAtPosition(pos)
}
public void onNothingSelected(AdapterView<?> parent) {
// Another interface callback
}
/**
* Background Async Task to Create new reclamation
* */
class CreateNewReclamation extends AsyncTask<String, String, String> {
/**
* Before starting background thread Show Progress Dialog
* */
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(NewReclamationActivity.this);
pDialog.setMessage("Creating Reclamation..");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}
/**
* Creating reclamation
* */
// Fetching user details from SQLite
HashMap<String, String> user = db.getUserDetails();
String user_id=user.get("uid");
String name = inputName.getText().toString();
String type = spinner.getSelectedItem().toString();
String description = inputDesc.getText().toString();
protected String doInBackground(String... args) {
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("name", name));
params.add(new BasicNameValuePair("type", type));
params.add(new BasicNameValuePair("description", description));
params.add(new BasicNameValuePair("user_id",user_id));
// getting JSON Object
// Note that create product url accepts POST method
JSONObject json = jsonParser.makeHttpRequest(AppConfig.url_create_reclamation,
"POST", params);
// check log cat fro response
Log.d("Create Response", json.toString());
// check for success tag
try {
int success = json.getInt(TAG_SUCCESS);
if (success == 1) {
// successfully created reclamation
Intent i = new Intent(getApplicationContext(), MainActivity.class);
startActivity(i);
// closing this screen
finish();
} else {
// failed to create reclamation
}
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
/**
* After completing background task Dismiss the progress dialog
* **/
protected void onPostExecute(String file_url) {
// dismiss the dialog once done
pDialog.dismiss();
}
}
Я хочу добавить вакансию, используя google map. Любые идеи, пожалуйста?
Мы не сможем помочь вам, пока вы не поделитесь с нами кодом –
Я отредактировал свою публикацию, вы можете найти мой код сейчас. я хочу добавить позицию с помощью карт Google и сохранить ее в базе данных. – salma
. Начните с этого момента: https://developers.google.com/maps/documentation/android-api/start, потому что вам нужно реализовать карты Google, прежде чем вы сможете получить позиция от пользователя. –