Hi, I am very new to developing apps and I am following the tutorial from Google's Android Training and I am currently at the "Starting your second Activity" stage. The purpose of the tutorial is to create a second activity so that the "Send" button will display the message that I have written.
There are 2 errors here:
Code:
Unknown member 'action_settings' of 'com.mycompany.myapp.R.id'
Unknown member 'fragment_display_message of 'com.mycompany.myapp.R.id'
and this is the code where the error occurs at DisplayMessageActivity java class:
Code:
import android.app.*;
import android.os.*;
import android.view.*;
import android.widget.*;
import android.content.*;
import com.mycompany.myapp.*;
public class DisplayMessageActivity extends Activity
{@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Get the message from the intent
Intent intent = getIntent();
String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
// Create the text view
TextView textView = new TextView(this);
textView.setTextSize(40);
textView.setText(message);
// Set the text view as the activity layout
setContentView(textView);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {
public PlaceholderFragment() { }
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_display_message,
container, false);
return rootView;
}
}
}
I can't seem to fix this error. I have been trying to find the solution but to no avail.
I don't kow if it help you guys but here's the R.java:
Code:
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package com.mycompany.myapp;
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int ic_launcher=0x7f020000;
}
public static final class id {
public static final int edit_message=0x7f050000;
}
public static final class layout {
public static final int main=0x7f030000;
}
public static final class string {
public static final int action_settings=0x7f040003;
public static final int app_name=0x7f040000;
public static final int button_send=0x7f040002;
public static final int edit_message=0x7f040001;
public static final int title_activity_display_message=0x7f040005;
public static final int title_activity_main=0x7f040004;
}
}
Here's the R java:
Code:
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package com.mycompany.myapp;
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int ic_launcher=0x7f020000;
}
public static final class id {
public static final int edit_message=0x7f050000;
}
public static final class layout {
public static final int main=0x7f030000;
}
public static final class string {
public static final int action_settings=0x7f040003;
public static final int app_name=0x7f040000;
public static final int button_send=0x7f040002;
public static final int edit_message=0x7f040001;
public static final int title_activity_display_message=0x7f040005;
public static final int title_activity_main=0x7f040004;
}
}
Here's the strings xml:
Code:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">My App</string>
<string name="edit_message">Enter a message</string>
<string name="button_send">Send</string>
<string name="action_settings">Settings</string>
<string name="title_activity_main">MainActivity</string>
<string name="title_activity_display_message">My Message</string>
</resources>
Here's the Mainactivity java
Code:
import android.app.*;
import android.os.*;
import android.view.*;
import android.widget.*;
import android.content.*;
import com.mycompany.myapp.*;
public class MainActivity extends Activity
{
public final static String EXTRA_MESSAGE = "com.example.myapp.MESSAGE";
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);}
public void sendMessage(View view) {
Intent intent = new Intent(this, DisplayMessageActivity.class);
EditText editText = (EditText) findViewById(R.id.edit_message);
String message = editText.getText().toString();
intent.putExtra(EXTRA_MESSAGE, message);
startActivity(intent);
}
}
Koopla said:
Hi, I am very new to developing apps and I am following the tutorial from Google's Android Training and I am currently at the "Starting your second Activity" stage. The purpose of the tutorial is to create a second activity so that the "Send" button will display the message that I have written.
There are 2 errors here:
Code:
Unknown member 'action_settings' of 'com.mycompany.myapp.R.id'
Unknown member 'fragment_display_message of 'com.mycompany.myapp.R.id'
and this is the code where the error occurs at DisplayMessageActivity java class:
Code:
import android.app.*;
import android.os.*;
import android.view.*;
import android.widget.*;
import android.content.*;
import com.mycompany.myapp.*;
public class DisplayMessageActivity extends Activity
{@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Get the message from the intent
Intent intent = getIntent();
String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
// Create the text view
TextView textView = new TextView(this);
textView.setTextSize(40);
textView.setText(message);
// Set the text view as the activity layout
setContentView(textView);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {
public PlaceholderFragment() { }
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_display_message,
container, false);
return rootView;
}
}
}
I can't seem to fix this error. I have been trying to find the solution but to no avail.
I don't kow if it help you guys but here's the R.java:
Code:
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package com.mycompany.myapp;
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int ic_launcher=0x7f020000;
}
public static final class id {
public static final int edit_message=0x7f050000;
}
public static final class layout {
public static final int main=0x7f030000;
}
public static final class string {
public static final int action_settings=0x7f040003;
public static final int app_name=0x7f040000;
public static final int button_send=0x7f040002;
public static final int edit_message=0x7f040001;
public static final int title_activity_display_message=0x7f040005;
public static final int title_activity_main=0x7f040004;
}
}
Here's the R java:
Code:
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package com.mycompany.myapp;
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int ic_launcher=0x7f020000;
}
public static final class id {
public static final int edit_message=0x7f050000;
}
public static final class layout {
public static final int main=0x7f030000;
}
public static final class string {
public static final int action_settings=0x7f040003;
public static final int app_name=0x7f040000;
public static final int button_send=0x7f040002;
public static final int edit_message=0x7f040001;
public static final int title_activity_display_message=0x7f040005;
public static final int title_activity_main=0x7f040004;
}
}
Here's the strings xml:
Code:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">My App</string>
<string name="edit_message">Enter a message</string>
<string name="button_send">Send</string>
<string name="action_settings">Settings</string>
<string name="title_activity_main">MainActivity</string>
<string name="title_activity_display_message">My Message</string>
</resources>
Here's the Mainactivity java
Code:
import android.app.*;
import android.os.*;
import android.view.*;
import android.widget.*;
import android.content.*;
import com.mycompany.myapp.*;
public class MainActivity extends Activity
{
public final static String EXTRA_MESSAGE = "com.example.myapp.MESSAGE";
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);}
public void sendMessage(View view) {
Intent intent = new Intent(this, DisplayMessageActivity.class);
EditText editText = (EditText) findViewById(R.id.edit_message);
String message = editText.getText().toString();
intent.putExtra(EXTRA_MESSAGE, message);
startActivity(intent);
}
}
Click to expand...
Click to collapse
You haven't created a layout for your second activity .
Create an xml layout file, called fragment_display_message, with at least a textview so that it can display your message, and add at least a textview to display the message
as far as action_settings string is concerned, it seems to be a problem with menu.xml file
if you don't wanna get into that, just delete these lines
PHP:
if (id == R.id.action_settings) {
return true;
}
Related
As described in manual, to use custom class in .aidl files, it must to implement Parcelable interface :
Code:
package com.shadower;
import android.os.Parcel;
import android.os.Parcelable;
public class Params implements Parcelable{
private long timeout;
public static final Parcelable.Creator<Params> CREATOR = new Parcelable.Creator<Params>() {
@Override
public Params createFromParcel(Parcel in) {
return new Params(in);
}
@Override
public Params[] newArray(int size) {
return new Params[size];
}
};
public Params(Parcel in) {
timeout = in.readLong();
}
public void writeToParcel(Parcel out) {
out.writeLong(timeout);
}
public void setTimeOut(long timeout) {
this.timeout = timeout;
}
public long getTimeout() {
return timeout;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel out, int flags) {
out.writeLong(timeout);
}
}
then must be imported into .aidl:
Code:
package com.shadower;
import com.shadower.IShadowerServiceCallback;
import com.shadower.Params;
....
but **** happens :
Code:
couldn't find import for class com.shadower.Params IShadowerService.aidl /shadower/src/com/shadower line 5 Android AIDL Problem
wtf is going on?
I am trying to pass information from a text view into an ImageView to move the ImageView. The problem is I can't use the TextView information because it is defined as a TextView. So is there a way I can get it to use the TextView as an integer?
Do you mean you want to convert the text string in the textview to an integer? There's the java.lang.Integer class which has a static member parseInt() which might do what you need:
http://developer.android.com/reference/java/lang/Integer.html#parseInt(java.lang.String)
Not completely sure what your looking for but if I read it right,
imageView.setMethod(parseInt(textView.getText()))
setMethod being which ever method your trying to set the int into.
I need the data from my accelerometer code which looks like so:
package com.bobhoil.tdodger;
import android.app.Activity;
import android.os.Bundle;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.widget.TextView;
public class TestActivity extends Activity implements SensorEventListener {
private TextView accelXValue;
private TextView accelYValue;
private TextView accelZValue;
private SensorManager sensorManager = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
setContentView(R.layout.test);
accelXValue = (TextView) findViewById(R.id.accel_x_value);
accelYValue = (TextView) findViewById(R.id.accel_y_value);
accelZValue = (TextView) findViewById(R.id.accel_z_value);
accelXValue.setText("0.00");
accelYValue.setText("0.00");
accelZValue.setText("0.00");
}
public void onSensorChanged(SensorEvent sensorEvent) {
synchronized (this) {
if (sensorEvent.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
accelXValue.setText(Float.toString(sensorEvent.values[0]));
accelYValue.setText(Float.toString(sensorEvent.values[1]));
accelZValue.setText(Float.toString(sensorEvent.values[2]));
}
}
}
public void onAccuracyChanged(Sensor arg0, int arg1) {
}
@Override
protected void onResume() {
super.onResume();
sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_GAME);
}
@Override
protected void onStop() {
sensorManager.unregisterListener(this);
super.onStop();
}
}
Click to expand...
Click to collapse
I need to put that into my imageview and use scrollby to move the imageview around the screen.
I'm not too familiar with imageviews, are you using XMLs for the layout or creating the imageViews programmaticly? I'm assuming the textViews and imageViews are in seperate classes. Thus the easiest way to get the text from the textViews would be to first give them the "protected" token rather than "private" and reference them directly.
Code:
imageView.scrollBy(parseInt(TestActivity.accelXValue.getText()));
I have tried that before but no matter what I try I get an error. Here is the error:
Cannot make a static reference to the non-static field TestActivity.accelXValue
Click to expand...
Click to collapse
So then I change it to static and get the following error:
The method parseInt(CharSequence) is undefined for the type TestActivity
Click to expand...
Click to collapse
I can't seem to get something that seems so simple to work.
Hi!
I develop Android since 1 year and if I read my first code, i put my hands over my hair
Days by days and lines by lines, the developer skill increased and after 1 year i collected some feature and block of code that I always use (some are like tips/triks).
I wanna share them with all of you and take suggestion or other block of codes you always use.
1) CONSTANTS CLASS
In this "final" class i put all constants and methods I need in my activities.
Code:
public final class Constants {
public static final boolean DEBUG = true;
public static final boolean LOG = true;
public static final String TAG = "APP_NAME";
public static final String TAG_PREFERENCE = "PREFERENCE";
public static final String TAG_WIDGET = "WIDGET";
public static final String marketlINK = "market://details?id=app.name.etc";
public static final String oldversion="0.9";
public static final String version="1";
public static final String getCurrentDate(){
Calendar c = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
String formattedDate = df.format(c.getTime());
return formattedDate;
}
}
2)LOG WRAPPER CLASS
This wrapper class allow to disable all log output in logcat.
It's possible to obtain the same results by using proguard.
Code:
public class Log {
static final boolean LOG = Constants.LOG;
public static void i(String tag, String string) {
if (LOG) android.util.Log.i(tag, string);
}
public static void e(String tag, String string) {
if (LOG) android.util.Log.e(tag, string);
}
public static void d(String tag, String string) {
if (LOG) android.util.Log.d(tag, string);
}
public static void v(String tag, String string) {
if (LOG) android.util.Log.v(tag, string);
}
public static void w(String tag, String string) {
if (LOG) android.util.Log.w(tag, string);
}
}
3)FIRST TIME LAUNCH
Check from sharedpreferences if it's the first time the app is launched.
Code:
final boolean firstTime = prefs.getBoolean(Constant.version, true);
if (firstTime){
editor.remove(Constant.oldversion);
editor.putBoolean(Constant.version, false);
editor.commit();
}
4)CHECK NUMBER OF START
Check how many times the app is launched and do something..
Code:
int counter = prefs.getInt("numRun", 0);
counter++;
prefs.edit().putInt("numRun",counter).commit();
if (counter==5){
openDialog();
prefs.edit().putInt("numRun",0).commit();
}
If you have suggestions or other block of code-lines, i'll include them on the first post!
reserved
Are you sure that youre developing android?
Sent from my ST18i using Tapatalk 2
Hi guys.
I've been developing an app which has Swipeable menu in bottom and one of the pages , should have a Navigation Drawer to change its own Fragments.
MainActivity.java
Code:
package com.example.elizehprotowithshlkandvpis;
import com.example.elizehprotowithshlkandvpis.adapter.MainMenuAdapter;
import com.viewpagerindicator.TabPageIndicator;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.Menu;
public class MainActivity extends FragmentActivity {
private static final String[] CONTENT = { "Home", "AboutUs", "Maps", "Resturants", "Tours", "CustomerClub", "Neccesseries", "UrgentCall" };
private ViewPager mViewPager;
private FragmentPagerAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
adapter = new MainMenuAdapter(getSupportFragmentManager());
mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setAdapter(adapter);
TabPageIndicator indicator = (TabPageIndicator) findViewById(R.id.indicator);
indicator.setViewPager(mViewPager);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public static String[] getCONTENT() {
return CONTENT;
}
}
MainMenuAdapter.java
Code:
package com.example.elizehprotowithshlkandvpis.adapter;
import com.example.elizehprotowithshlkandvpis.MainActivity;
import com.example.menuclasses.AboutUs;
import com.example.menuclasses.CustomerClub;
import com.example.menuclasses.Maps;
import com.example.menuclasses.Neccesseries;
import com.example.menuclasses.Tours;
import com.example.menuclasses.UrgentCall;
import com.example.menuclasses.Resturants;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
public class MainMenuAdapter extends FragmentPagerAdapter {
private static final String[] CONTENT = { "Home", "AboutUs", "Maps", "Resturants", "Tours", "CustomerClub", "Neccesseries", "UrgentCall" };
private final int HOME_INDEX = 0;
private final int ABOUTUS_INDEX = 1;
private final int MAPS_INDEX = 2;
private final int RESTURANTS_INDEX = 3;
private final int TOURS_INDEX = 4;
private final int CUSTOMERCLUB_INDEX = 5;
private final int NECCESSERIES_INDEX = 6;
private final int URGENTCALL_INDEX = 7;
private final int NUMBEROFMENUS = CONTENT.length;
public MainMenuAdapter(FragmentManager fm) {
super(fm);
// TODO Auto-generated constructor stub
}
@Override
public CharSequence getPageTitle(int position) {
String[] CONTENT = MainActivity.getCONTENT();
return CONTENT[position % CONTENT.length].toUpperCase();
}
@Override
public Fragment getItem(int index) {
switch(index) {
case HOME_INDEX:
return new AboutUs();
case ABOUTUS_INDEX:
return new AboutUs();
case MAPS_INDEX:
return new Maps();
case RESTURANTS_INDEX:
return new Resturants();
case TOURS_INDEX:
return new Tours();
case CUSTOMERCLUB_INDEX:
return new CustomerClub();
case NECCESSERIES_INDEX:
return new Neccesseries();
case URGENTCALL_INDEX:
return new UrgentCall();
}
return null;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return NUMBEROFMENUS;
}
}
The Fragment that should contain a Navigation Drawer is Resturants , also drawer's mainactivity is implemented with Sherlock Library(SherlockFragmentActivity).
I'm puzzled how to call the SherlockFragmentActivity from the SherlockActivity
Thanks
Pouya_am said:
Hi guys.
I've been developing an app which has Swipeable menu in bottom and one of the pages , should have a Navigation Drawer to change its own Fragments.
MainActivity.java
Code:
package com.example.elizehprotowithshlkandvpis;
import com.example.elizehprotowithshlkandvpis.adapter.MainMenuAdapter;
import com.viewpagerindicator.TabPageIndicator;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.Menu;
public class MainActivity extends FragmentActivity {
private static final String[] CONTENT = { "Home", "AboutUs", "Maps", "Resturants", "Tours", "CustomerClub", "Neccesseries", "UrgentCall" };
private ViewPager mViewPager;
private FragmentPagerAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
adapter = new MainMenuAdapter(getSupportFragmentManager());
mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setAdapter(adapter);
TabPageIndicator indicator = (TabPageIndicator) findViewById(R.id.indicator);
indicator.setViewPager(mViewPager);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public static String[] getCONTENT() {
return CONTENT;
}
}
MainMenuAdapter.java
Code:
package com.example.elizehprotowithshlkandvpis.adapter;
import com.example.elizehprotowithshlkandvpis.MainActivity;
import com.example.menuclasses.AboutUs;
import com.example.menuclasses.CustomerClub;
import com.example.menuclasses.Maps;
import com.example.menuclasses.Neccesseries;
import com.example.menuclasses.Tours;
import com.example.menuclasses.UrgentCall;
import com.example.menuclasses.Resturants;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
public class MainMenuAdapter extends FragmentPagerAdapter {
private static final String[] CONTENT = { "Home", "AboutUs", "Maps", "Resturants", "Tours", "CustomerClub", "Neccesseries", "UrgentCall" };
private final int HOME_INDEX = 0;
private final int ABOUTUS_INDEX = 1;
private final int MAPS_INDEX = 2;
private final int RESTURANTS_INDEX = 3;
private final int TOURS_INDEX = 4;
private final int CUSTOMERCLUB_INDEX = 5;
private final int NECCESSERIES_INDEX = 6;
private final int URGENTCALL_INDEX = 7;
private final int NUMBEROFMENUS = CONTENT.length;
public MainMenuAdapter(FragmentManager fm) {
super(fm);
// TODO Auto-generated constructor stub
}
@Override
public CharSequence getPageTitle(int position) {
String[] CONTENT = MainActivity.getCONTENT();
return CONTENT[position % CONTENT.length].toUpperCase();
}
@Override
public Fragment getItem(int index) {
switch(index) {
case HOME_INDEX:
return new AboutUs();
case ABOUTUS_INDEX:
return new AboutUs();
case MAPS_INDEX:
return new Maps();
case RESTURANTS_INDEX:
return new Resturants();
case TOURS_INDEX:
return new Tours();
case CUSTOMERCLUB_INDEX:
return new CustomerClub();
case NECCESSERIES_INDEX:
return new Neccesseries();
case URGENTCALL_INDEX:
return new UrgentCall();
}
return null;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return NUMBEROFMENUS;
}
}
The Fragment that should contain a Navigation Drawer is Resturants , also drawer's mainactivity is implemented with Sherlock Library(SherlockFragmentActivity).
I'm puzzled how to call the SherlockFragmentActivity from the SherlockActivity
Thanks
Click to expand...
Click to collapse
That last sentence does not make sense I assume you mean from the Fragment?! Well to access the holding activity you need to add an interface to the Fragment which the activity will implement.
Am I understanding you correctly that have a horizontal ViewPager and one of the Fragments should have a Navigation drawer? To accomplish that you would still need the whole activity to hold the drawer and figure out a way to disable it when the user is on some other Fragment. But my question is why you want to use a navigation drawer in that case, because the drawer is meant for navigating on the same hierarchical level, but the different items are more independent than with the ViewPager. It doesn't really make sense to have both a drawer and horizontal swiping, even the YouTube app really bothers me with its swiping between suggestions and feed. I think what you need to use here is a spinner in the ActionBar, replacing the title of the Fragment.
SimplicityApks said:
That last sentence does not make sense I assume you mean from the Fragment?! Well to access the holding activity you need to add an interface to the Fragment which the activity will implement.
Am I understanding you correctly that have a horizontal ViewPager and one of the Fragments should have a Navigation drawer? To accomplish that you would still need the whole activity to hold the drawer and figure out a way to disable it when the user is on some other Fragment. But my question is why you want to use a navigation drawer in that case, because the drawer is meant for navigating on the same hierarchical level, but the different items are more independent than with the ViewPager. It doesn't really make sense to have both a drawer and horizontal swiping, even the YouTube app really bothers me with its swiping between suggestions and feed. I think what you need to use here is a spinner in the ActionBar, replacing the title of the Fragment.
Click to expand...
Click to collapse
Yeah you're right , I just want to use the drawer in order to change contents.
So as you suggest , I just have to use a simple tricks to make the drawer enable in desire Fragment.
I don't want to , I am asked to make it possible....
Hi developers
Im have question
Im want to create setting activity
To set the font of app and theme of app
But i can't create set font setting
Here code from AIDE:
import android.app.*;
import android.os.*;
import android.widget.*;
import android.widget.AdapterView.*;
import android.view.*;
public class Setting extends Activity
{
public static String font = "B Nazanin";
public static int[] name ={1, 2, 3, 4};
public static long b; @override
public void onCreate(Bundle savedInstanceState)
{
// TODO: Implement this method
super.onCreate(savedInstanceState);
setContentView(R.layout.settings);
Spinner fontspin = (Spinner) findViewById(R.id.Settings_Spinner1);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
this, R.array.fonts, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
fontspin.setAdapter(adapter);
fontspin.setOnItemSelectedListener(
new OnItemSelectedListener()
{
@override
public void onNothingSelected(AdapterView<?> parent)
{
// TODO: Implement this method
}
public void onItemSelected(AdapterView<?> parent, View view, int position,long id)
{
if(id = 1)
{
b = 1;
}
}
});
}
public void onBackClick(View view)
{
finish();
}
}
Error: if(id =1) : a conidtion must be 'boolean'
How to fix this error?
Sent from my Lenovo A3000-H using Tapatalk
change if(id = 1) to if(id == 1)
you can set typeface in xml file