Android App stops when button clicked - android

I am trying to write an app that has 4 menu buttons on the main screen. On clicking this each menu button, a new screen should appear. At the moment I have only written code to cater for the first button to be clicked, but it the app crashes/stops.
I think the problem is that I don't have the activity of TheCompany declared in the Android Manifest file, but I don't know how I would do that.
I am writing the app in Eclipse and so far I have the following files/sets of code:
MainActivity.Java:
public class MainActivity extends Activity {
public final static String EXTRA_MESSAGE = "com.example.myfirstapp.MESSAGE";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
View button = findViewById(R.id.TheCompany);
button.setOnClickListener(new OnClickListener(){
public void onClick (View v){
startIntent();
}
});
//getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// If your minSdkVersion is 11 or higher, instead use:
// getActionBar().setDisplayHomeAsUpEnabled(true);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu items for use in the action bar
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_activity_actions, menu);
return super.onCreateOptionsMenu(menu);
}
/** Called when the user clicks the Company button */
private void startIntent() {
// Do something in response to button
Intent intent = new Intent(this, TheCompany.class);
startActivity(intent);
}
}
The Activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="The Company"
android:id="#+id/TheCompany"/>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Services"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Contacts" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Structure" />
</LinearLayout>
</LinearLayout>
Then I have the TheCompany Java file:
public class TheCompany extends Activity
{
public void onCreate(Bundle icicle)
{
super.onCreate(icicle);
setContentView(R.layout.company);
}
}
The Android.Manifest looks like:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myfirstapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:icon="#drawable/logo"
android:name="com.example.myfirstapp.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.myfirstapp.DisplayMessageActivity"
android:label="#string/title_activity_display_message"
android:parentActivityName="com.example.myfirstapp.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.myfirstapp.MainActivity" />
</activity>
</application>
</manifest>

Simply add this in your Manifest "application" tag :
<activity
android:name="com.example.myfirstapp.TheCompany"
android:label="#string/app_name" >
</activity>
You need to declare each activity in the manifest file.
The result is this :
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myfirstapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:icon="#drawable/logo"
android:name="com.example.myfirstapp.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.myfirstapp.TheCompany"
android:label="#string/app_name" >
</activity>
<activity
android:name="com.example.myfirstapp.DisplayMessageActivity"
android:label="#string/title_activity_display_message"
android:parentActivityName="com.example.myfirstapp.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.myfirstapp.MainActivity" />
</activity>
</application>
</manifest>

you did`t create any id like "TheCompany" in activity_main.xml, you have to declare id for button and then get the id using findViewById(...);
View button = findViewById(R.id.button1);

Related

Error inflating class android.support.v7.widget.SearchView. Similar questions on SO did not solve it

Here is an SSCCE. I am using 23.1.1 version of appcompat_v7 support library. I am running it on a Genymotion emulator with version 23 of Android SDK.
The exact error from the logcat is given at the end.
activity_main.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<android.support.v7.widget.SearchView
android:id="#+id/mainActivity_searchView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
MainActivity.java:
public class MainActivity extends Activity {
SearchView searchView;
TextView textView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
searchView = (SearchView) findViewById(R.id.mainActivity_searchView);
textView = (TextView) findViewById(R.id.textView);
searchView.setSearchableInfo(((SearchManager) getSystemService(SEARCH_SERVICE)).getSearchableInfo(getComponentName()));
searchView.setIconifiedByDefault(false);
handleIntent(getIntent());
}
#Override
protected void onNewIntent(Intent intent) {
setIntent(intent);
handleIntent(intent);
}
private void handleIntent(Intent intent) {
if (intent.getAction().equals(Intent.ACTION_SEARCH)) {
String searchQuery = intent.getStringExtra(SearchManager.QUERY);
performSearch(searchQuery);
}
}
private void performSearch(String searchQuery) {
textView.setText(searchQuery);
}
}
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="tests.test"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="23" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="tests.test.module_s.ui.MainActivity"
android:label="#string/app_name"
android:launchMode="singleTop" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="#xml/searchable" />
</activity>
<meta-data android:name="android.app.default_Searchable"
android:value=".MainActivity" />
</application>
</manifest>
LOGCAT:
java.lang.RuntimeException: Unable to start activity ComponentInfo{tests.test/tests.test.module_s.ui.MainActivity}: android.view.InflateException: Binary XML file line #6: Binary XML file line #6: Error inflating class android.support.v7.widget.SearchView

Android layout title bar is not visible

I have created xml layout file. And when I give it as content to my Activity the TITLE BAR IS NOT VISIBLE. How can I make it visible. I tried to use setTitle("Title");
protected void onCreate(Bundle savedInstanceState) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.onCreate(savedInstanceState);
Bundle b = getIntent().getExtras();
int layoutId = b.getInt("layout");
Log.d("====>>>", " " + layoutId);
setContentView(layoutId);
setTitle("Title");
}
function in onCreate() method. I is not work. This is my xml file.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<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:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
tools:context="com.universityapp.enrollee.FacultyInformationActivity"
android:scrollbars="vertical"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="#string/text_faculty_information_agro"
android:textSize="15dp"
android:textAlignment="center"
/>
</RelativeLayout>
</ScrollView>
I start activity via ListView:
profListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
switch (position){
case 0:
facultyInfoIntent = new Intent(getBaseContext(), FacultyInformationActivity.class);
Bundle b = new Bundle();
b.putInt("layout", facultyLayoutNames[position]);
facultyInfoIntent.putExtras(b);
startActivity(facultyInfoIntent);
}
Log.d("Selected faculty", facultiNames[position]);
}
});
This is my Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.universityapp.universityapp" >
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity android:name="com.universityapp.common.MainActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.universityapp.common.MenuActivity"
android:label="Главное меню" >
</activity>
<activity
android:name="com.universityapp.enrollee.ContacsActivity"
android:label="Наши контакты" >
</activity>
<activity
android:name="com.universityapp.enrollee.Map"
android:label="#string/title_activity_map" >
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="#string/google_maps_key" />
<activity
android:name="com.universityapp.enrollee.MapsActivity"
android:label="#string/title_activity_maps" >
</activity>
<activity
android:name="com.universityapp.bachelor.PlatonusActivity"
android:label="#string/title_activity_platonus" >
</activity>
<activity
android:name="com.universityapp.database.DatabaseActivity"
android:label="#string/title_activity_database" >
</activity>
<activity
android:name="com.universityapp.enrollee.EnrUniversityInfo"
android:label="#string/title_activity_enr_university_info" >
</activity>
<activity
android:name="com.universityapp.enrollee.ProfessionsActivity"
android:label="#string/title_activity_professions" >
</activity>
<activity
android:name="com.universityapp.enrollee.FacultyInformationActivity"
android:label="#string/title_activity_faculty_information" >
</activity>
</application>
</manifest>
Change:
public class MainActivity extends Activity{
}
in your class file to:
public class MainActivity extends AppCompatActivity{
}
I found the answer! I have changed Activity to ActionBarActivity and it works!
To show the title bar you can use this in your onCreate:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
You can do it by doing this (as suggested by HafizWaleedHussain):
public void showTitle() {
try {
((View) findViewById(android.R.id.title).getParent())
.setVisibility(View.VISIBLE);
} catch (Exception e) {
}
getWindow().addFlags(
WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
If this didn't work then open your Android Manifest file and remove this line if it exist:
android:theme="#android:style/Theme.NoTitleBar"
Got o styles.xml and make a new style
<style name="CustomWindowTitleBackground">
<item name="android:background">#323331</item>
<item name="android:windowNoTitle">false</item>
</style>
and call it from Manifest (You can also add other features inside item tags)
<activity
android:name=".st.activity.MyGoogleMap"
android:theme="#style/CustomWindowTitleBackground">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I removed the statement android:theme="#style/AppTheme" in the application tag and the bar started appearing
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
**android:theme="#style/AppTheme"**>

listView doesn't appear at all. android

listView doesn't appear at all (the activity is white with few things I added (buttons)) and I don't know if its important but this is not my main activity.
edit: I added xml for main activity and items
public class CarsMenu extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cars_menu);
runListView();
clickFun();
}
private void clickFun() {
ListView list = (ListView) findViewById(R.id.MlistView);
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View viewClicked, int position, long id) {
TextView textView = (TextView) viewClicked;
Toast.makeText(getApplicationContext(), "clicked", Toast.LENGTH_SHORT).show();
}
});
}
private void runListView(){
String[] getCars = {"blue", "green", "purple", "red"};
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.items, getCars);
ListView list = (ListView) findViewById(R.id.MlistView);
list.setAdapter(adapter);
}
}
activity xml
activity xml
<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"
tools:context="${packageName}.${activityClass}" >
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:onClick="btnCarClick"
android:text="Refresh" />
<ListView
android:id="#+id/MlistView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/button1"
android:layout_centerHorizontal="true" >
</ListView>
</RelativeLayout>
items xml
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</TextView>
android manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.http"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.http.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.http.Exception_Error"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/title_activity_exception__error"
android:theme="#style/FullscreenTheme" >
</activity>
<activity
android:name="com.example.http.Menu_Activity"
android:label="#string/title_activity_menu_" >
</activity>
<activity
android:name="com.example.http.Dev"
android:label="#string/title_activity_dev" >
</activity>
<activity
android:name="com.example.http.AllCars"
android:label="#string/title_activity_all_cars" >
</activity>
<activity
android:name="com.example.http.Cars"
android:label="#string/title_activity_cars" >
</activity>
<activity
android:name="com.example.http.CarsMenu"
android:label="#string/title_activity_cars_menu" >
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET" >
</uses-permission>
</manifest>
Your "items.xml" object has it's height equal to the parent - so only one item will be visible in your listview. Change it to:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</TextView>

Nothing is displayed in screen after running android program

I have written an android application to display a list. Code has taken from an example. There is no error in compiling, but nothing is displayed on after running the application. Expecting you help to solve this problem thanks. Please find below code i used...
Main Activity
public class MainActivity extends ListActivity {
ArrayList<String> listItems=new ArrayList<String>();
ArrayAdapter<String> adapter;
int clickCounter=0;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
listItems.add("Hello");
adapter=new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, listItems);
setListAdapter(adapter);
}
public void addItems(View v) {
listItems.add("Clicked : "+clickCounter++);
adapter.notifyDataSetChanged();
}
}
mainactivity.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<Button
android:id="#+id/addBtn"
android:text="Add New Item"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="addItems"/>
<ListView
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:drawSelectorOnTop="false"
/>
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.testlistview"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="android.app.ListActivity" />
</activity>
</application>
</manifest>
Please add the following intentfilter to the manifest:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Android needs this intent filter to know which activity to start.
You may have set the wrong content view in MainActivity.
Try to replace the setContentView statement with the following one:
setContentView(R.layout.mainactivity.xml);

android button click not working in program

Hello everybody i have a problem that when i click a button it remains as it is instead of starting new activity. I searched he problem in this site and found some solutions but none of them worked for me so i am writing my problem here.
the xml layout is
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/profile_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/profile" />
<Button
android:id="#+id/create_profile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="#string/create_profile" />
<Button
android:id="#+id/edit_profile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#id/create_profile"
android:text="#string/edit_profile" />
<Button
android:id="#+id/delete_profile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#id/edit_profile"
android:text="#string/delete_profile" />
<Button
android:id="#+id/activate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#id/delete_profile"
android:text="#string/activate" />
<ListView
android:id="#id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#id/create_profile"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_below="#id/profile_title" />
<TextView
android:id="#id/android:empty"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#id/create_profile"
android:layout_below="#id/profile_title"
android:gravity="center_vertical|center_horizontal"
android:text="#string/no_profiles" />
</RelativeLayout>
and the activity is
package com.android.SmartSwitch;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class Profile_Manager extends Activity {
private Button createButton;
private Button editButton;
private Button deleteButton;
private Button activateButton;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.profile);
setUpViews();
}
private void setUpViews() {
createButton = (Button)findViewById(R.id.create_profile);
editButton = (Button)findViewById(R.id.edit_profile);
deleteButton = (Button)findViewById(R.id.delete_profile);
activateButton = (Button)findViewById(R.id.activate);
createButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent intent = new Intent(Profile_Manager.this, Add_Profile.class);
startActivity(intent);
}
});
editButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
}
});
deleteButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
}
});
activateButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
}
});
}
}
androidmanifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.SmartSwitch"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:label="#string/app_name"
android:name=".SmartSwitchActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Location_Manager" android:label="#string/app_name"/>
<activity android:name=".Profile_Manager" android:label="#string/app_name"/>
<activity android:name=".Schedule_Manager" android:label="#string/app_name"/>
<activity android:name=".Location_In_Map" android:label="#string/app_name"/>
<activity android:name=".Add_Profile" android:label="#string/app_name"/>
<uses-library android:name="com.google.android.maps" />
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
</manifest>
When i click createButton, it doesn't respond
As your Main Activity i.e., Profile_Manager consists of the following Code:
<activity
android:label="#string/app_name"
android:name=".SmartSwitchActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
You have to note if the Profile Manager class is the class which will be launched i.e., if Profile_Manager Class is the First Screen then, you should create the above code in AndroidManifest.xml with the only change as android:name=".Profile_Manager" instead of "SmartSwitchActivity" with the code additionally added for Add_Profile class as follows
<activity
android:label="#string/app_name"
android:name=".Add_Profile" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
I suppose by doing this changes,things will work fine.
If you are not able to understand the above working then,Here is the Link with Perfect Working Example and with available Source Code-Correct Working of Button Click

Categories

Resources