Click here to Skip to main content
15,888,116 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Main Activity
Java
package com.maurya.appcontrol;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;


public class MainActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button but2 = (Button) findViewById(R.id.button1);
        but2.setOnClickListener(new View.OnClickListener() {

            Intent in = new Intent("com.example.appcontrol.Pref");

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                startActivity(in);
            }
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }
}


preference screen activity
Java
package com.maurya.appcontrol;

import android.app.Activity;
import android.os.Bundle;
public class Backup extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        //--load the preferences from an XML file---
        addPreferencesFromResource"(int appsbackup)";

Sir i am new but learning from the web. I tried to make a simple apk wherein ckick on the text lead to separate activity screen. BUT I AM GETING ERROR the (addPreferencesFromResource"(int appsbackup). I TRIED EVEN (R.xml.appsbackup), but error persist.

can you please help me out. Another related question is whether i can link the multiple preference activity screen with list text in main screen...

Regards
Posted
Updated 2-Apr-15 3:30am
v8

1 solution

addPreferencesFromResource(int id) had been deprecated, try PreferenceActivity[^] instead. It has a sample code.
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 2-Apr-15 11:36am    
5ed.
—SA
Peter Leow 2-Apr-15 11:42am    
Thank you, Sergey.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900