• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps android:id problem

pauleee

Lurker
Sep 20, 2013
2
0
hello, i am new to android development and eclipse ,, please assist with this simple issue cause its got me...

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:id="@+id/main_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:eek:rientation="vertical" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/red" />

<SeekBar
android:id="@+id/red_seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="255" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/blue" />

<SeekBar
android:id="@+id/blue_seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="255" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/green"
android:max="255" />

<SeekBar
android:id="@+id/green_seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="255" />

</LinearLayout>





package com.example.colors;

import android.os.Bundle;
import android.app.Activity;
import android.graphics.Color;
import android.widget.LinearLayout;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;

public class MainActivity extends Activity implements OnSeekBarChangeListener
{
private LinearLayout frame;
private SeekBar redSeekBar, blueSeekBar, greenSeekBar;

@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

frame = (LinearLayout) findViewById(R.id.main_frame);

redSeekBar = (SeekBar) findViewById(R.id.red_seekbar);
blueSeekBar = (SeekBar) findViewById(R.id.blue_seekbar);
greenSeekBar = (SeekBar) findViewById(R.id.green_seekbar);

redSeekBar.setOnSeekBarChangeListener(this);
blueSeekBar.setOnSeekBarChangeListener(this);
greenSeekBar.setOnSeekBarChangeListener(this);
}

@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser)
{
frame.setBackgroundColor(getColorFromSeekbars());
}

@Override
public void onStartTrackingTouch(SeekBar seekBar)
{
// do nothing
}

@Override
public void onStopTrackingTouch(SeekBar seekBar)
{
// do nothing
}

private int getColorFromSeekbars()
{
return Color.argb(255, redSeekBar.getProgress(),
greenSeekBar.getProgress(), blueSeekBar.getProgress());
}
}


The error is the following R.id values "cannot be resolved or is not a field."

frame = (LinearLayout) findViewById(R.id.main_frame);

redSeekBar = (SeekBar) findViewById(R.id.red_seekbar);
blueSeekBar = (SeekBar) findViewById(R.id.blue_seekbar);
greenSeekBar = (SeekBar) findViewById(R.id.green_seekbar);

Assistance is greatly appreciated..

Thanks Paul
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones