I have created a chatroom where user can discuss on several Topic. I'm using a Scrollview inside RelativeLayout which contains chatConversation
The Porblem is when user opens app then he has to scroll to the Bottom HImself to chat or view the new chat discussion.
How can I force scrollview to start at Bottom when activity is started..
Below is my layout file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:theme="#style/AppTheme.NoActionBar"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.v7.widget.Toolbar
android:id="#+id/main_chat"
app:titleTextAppearance="#style/Toolbar.TitleText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#F0791F"
android:theme="#style/ThemeOverlay.AppCompat.Light"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:navigationIcon="#drawable/ic_people_outline_black_24dp"/>
<Button
android:id="#+id/btn_send"
android:layout_width="42dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:background="#android:color/transparent"
android:drawableLeft="#drawable/ic_send_black_24dp" />
<EditText
android:id="#+id/msg_input"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignTop="#+id/btn_send"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="#+id/btn_send"
android:layout_toStartOf="#+id/btn_send"
android:background="#null"
android:hint="Write a message" />
<ScrollView
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/scrollView"
android:transcriptMode="alwaysScroll"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_above="#+id/btn_send"
android:layout_below="#+id/main_chat"
android:layout_alignRight="#+id/btn_send"
android:layout_alignEnd="#+id/btn_send">
<TextView
android:id="#+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginTop="2dp"
android:layout_weight="2"
android:autoLink="all" />
</ScrollView>
<View
android:layout_above="#+id/msg_input"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#android:color/darker_gray"/>
</RelativeLayout>
I already tried using
final ScrollView scrollLayout = ((ScrollView) findViewById(R.id.scrollView));
scrollLayout.post(new Runnable() {
#Override
public void run() {
scrollLayout.fullScroll(ScrollView.FOCUS_DOWN);
}
});
But it doesn't work either.
Please Help
How are you displaying the messages? With a While Loop?
Last line of the while loop should be...
mScrollView.fullScroll(ScrollView.FOCUS_DOWN);
mScrollView or whatever name you gave to the ScrollView
I think you're appending the messages in a single TextView (correct me if I'm wrong).
Check if you are invoking fullScroll() after you are finished appending all the text in your TextView.
for (String oneMessage : messageList){
myTextView.append(oneMessage);
myTextView.append("\n");
....
....
}
//Scroll to bottom
scrollLayout.post(new Runnable() {
#Override
public void run() {
boolean success = scrollLayout.fullScroll(ScrollView.FOCUS_DOWN);
Log.d("Auto Scroll", success ? "Done" : "Failed");
}
});
Let me know if this fixed your issue!
Related
I only want my textview with id clickable_txtView to be clickable in relative layout. Here is the code -
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="#android:id/empty"
android:clickable="false">
<ImageView
android:layout_width="120sp"
android:layout_height="130sp"
android:layout_centerHorizontal="true"
android:src="#drawable/flower"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingTop="120sp"
android:text="Dont click me />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/clickable_txtView"
android:gravity="center"
android:paddingTop="140sp"
android:clickable="true"
android:text="Click me" />
</RelativeLayout>
#OnClick(R.id.clickable_txtView)
public void txtViewClick() {
//Some event
}
Thr problem is I am able to click whole relative layout and some event happens after onclicking relative layout.
How do I avoid this and make it limited to text view only.
Your textview has an attribute android:paddingTop="140sp" which basically wraps over the entire relative layout, because of which you are having the problem with onClick behaviour.
Use this RelativeLayout structure (provide ID to the "don't click me" textview, and place the "clickable textview" below it.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/empty"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center">
<ImageView
android:layout_width="120sp"
android:layout_height="130sp"
android:layout_centerHorizontal="true"
android:src="#mipmap/ic_launcher"
android:layout_alignParentTop="true"
/>
<TextView
android:id="#+id/do_not_click"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingTop="120sp"
android:enabled="false"
android:text="Dont click me" />
<TextView
android:id="#+id/clickable_txtView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:gravity="center"
android:layout_below="#id/do_not_click"
android:text="Click me" />
</RelativeLayout>
In your activity where you are inflating this view try this:
first initialize your textview
TextView textView = (TextView) findViewById(R.id.clickable_txtView);
then apply clickListner on it
textView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
//Do your work here
}
});
I'm not sure but you can try adding below line to your parent layout
android:touchscreenBlocksFocus="true"
like
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="#android:id/empty"
android:touchscreenBlocksFocus="true">
I'm creating a game and in it I use a lot of dialogs. The dialogs make up the main menu in a more simple setup then making up an entire activity for it. These dialogs though, they have a grey outline which is really annoying, and in addition when going from one dialog to another, it shrinks down and blows up as one dissapears and another one reappears.
How can I remove the outline and make the transition more smooth? If it is not possible with dialogs, what can an alternative be? I am using custom layouts connected to Java classes that extend Dialog
EDIT
Java:
public class MenuDialog extends Dialog implements View.OnClickListener {
Context con;
Clicker c;
public MenuDialog(Context c, Clicker game) {
super(c);
this.con = c;
this.c = game;
Window window = this.getWindow();
window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
requestWindowFeature(Window.FEATURE_NO_TITLE);
show();
}
Button stat, gem, cash, shop, powerup, settings;
#Override
protected void onCreate(Bundle sis){
super.onCreate(sis);
setContentView(R.layout.menu);
setButtons();
}
private void setButtons(){
stat = (Button) findViewById(R.id.bStats);
gem = (Button) findViewById(R.id.bGems);
gem.setOnClickListener(this);
stat.setOnClickListener(this);
}
#Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.bStats:
StatDialog sd = new StatDialog(con,c);
sd.show();
break;
case R.id.bGems:
IAPDialog iapd = new IAPDialog(con, c);
iapd.show();
break;
//other buttons
}
dismiss();
}
}
XML:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible"
android:id="#+id/relativeLayout"
android:gravity="center_horizontal"
android:background="#drawable/phone_like_bc"
android:orientation="horizontal">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/linearLayout5"
android:layout_marginTop="51dp">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/bStats"
android:layout_alignParentTop="true"
android:layout_toLeftOf="#+id/bGems"
android:background="#drawable/stat_button"
android:layout_toStartOf="#+id/bGems" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/stats"
android:id="#+id/textView17"
android:layout_below="#+id/bStats"
android:layout_alignLeft="#+id/bStats"
android:layout_alignStart="#+id/bStats" />
<Button
android:layout_width="100dp"
android:layout_height="100dp"
android:id="#+id/bShop"
android:background="#drawable/shop"
android:layout_below="#+id/textView17" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/shop"
android:textAlignment="center"
android:id="#+id/textView18"
android:layout_alignTop="#+id/textView16"
android:layout_alignLeft="#+id/bShop"
android:layout_alignStart="#+id/bShop" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="#+id/linearLayout"
android:layout_marginTop="51dp"
>
<Button
android:layout_width="100dp"
android:layout_height="100dp"
android:background="#drawable/gem"
android:id="#+id/bGems"
android:layout_centerVertical="true"
android:layout_toRightOf="#+id/linearLayout5"
android:layout_toEndOf="#+id/linearLayout5" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/gems"
android:id="#+id/textView15"
android:layout_alignBaseline="#+id/textView20"
android:layout_alignBottom="#+id/textView20"
android:layout_toLeftOf="#+id/bPowerUp"
android:layout_toStartOf="#+id/bPowerUp"
android:layout_gravity="center_horizontal" />
<Button
android:layout_width="100dp"
android:layout_height="100dp"
android:id="#+id/bPowerUp"
android:background="#drawable/lightning"
android:layout_alignTop="#+id/linearLayout"
android:layout_toLeftOf="#+id/bSettings"
android:layout_toStartOf="#+id/bSettings" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/powerups"
android:id="#+id/textView16"
android:layout_alignBaseline="#+id/bSettings"
android:layout_alignBottom="#+id/bSettings"
android:layout_toLeftOf="#+id/bSettings"
android:layout_toStartOf="#+id/bSettings" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="51dp"
android:gravity="center">
<Button
android:layout_width="100dp"
android:layout_height="100dp"
android:id="#+id/bCash"
android:background="#drawable/cash"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:text=" " />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/cash"
android:id="#+id/textView19"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_gravity="center_horizontal" />
<Button
android:layout_width="100dp"
android:layout_height="100dp"
android:id="#+id/bSettings"
android:background="#drawable/settings"
android:layout_below="#+id/bCash"
android:layout_alignLeft="#+id/bCash"
android:layout_alignStart="#+id/bCash" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/settings"
android:id="#+id/textView20"
android:layout_alignBottom="#+id/bCash"
android:layout_alignLeft="#+id/textView19"
android:layout_alignStart="#+id/textView19" />
</LinearLayout>
</LinearLayout>
There are two more dialog classes both XML and java. I added those two to show that I already know how to add the classes, but I need to know how to remove the outline of the dialog and I need to know how I can smoothen the transition between two dialogs. They have the same background too.
You can use DialogFragments instead of Dialogs, they works as Fragments and you can customize them. Read more about the use of Dialog fragments at https://developer.android.com/reference/android/app/DialogFragment.html
You have a lot of Tutorials to create your own DialogFragments in Google if you don't like the Android Documentation.
I'm working on my first Android project, which means that I'm not that familiar with Android and Java, and I want to move scroll of ScrollView after a user presses the button for next action (IME_ACTION_SEND). My codes are as follows.
activity_add.xml
It basically consists of TextView, EditText, NumberPicker, Spinner, Button. I want to move the scroll after IME_ACTION_SEND on EditText, so that the NumberPicker is centered on the screen.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/addActivity_scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="15dp">
<LinearLayout
android:id="#+id/layout_activity_add"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/title_addItem"
android:id="#+id/textView"
android:layout_gravity="center_horizontal"
android:textSize="40sp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:id="#+id/formLayout"
android:layout_marginTop="50dp">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/title_editText"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:hint="#string/hint_title"
android:singleLine = "true"
android:maxLength="20" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:id="#+id/formLayout3"
android:layout_marginTop="50dp">
<TextView
android:id="#+id/period_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/label_period"
android:layout_centerHorizontal="true" />
<NumberPicker
android:id="#+id/period_number_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/period_textView"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true">
</NumberPicker>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:id="#+id/formLayout4"
android:layout_marginTop="25dp"
android:layout_marginBottom="25dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/label_category"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_centerInParent="true"
android:layout_toStartOf="#+id/background_spinner"
android:layout_toLeftOf="#+id/background_spinner" />
<Spinner
android:id="#+id/background_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:layout_gravity="center_vertical">
</Spinner>
</RelativeLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/button_submit"
android:layout_gravity="center_horizontal"
android:text="#string/label_submit" />
</LinearLayout>
</ScrollView>
AddItemActivity.java
I've just copied the part which I think is relevant.
public class AddSinceItemActivity extends ActionBarActivity {
EditText title;
Spinner spinner;
NumberPicker numberPicker;
String title_string;
ViewGroup linearLayout;
ScrollView addActivity_scrollview;
#Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add);
addActivity_scrollview = (ScrollView) findViewById(R.id.addActivity_scrollview);
linearLayout = (ViewGroup) findViewById(R.id.layout_activity_add);
title = (EditText) findViewById(R.id.title_editText);
numberPicker = (NumberPicker) findViewById(R.id.period_number_picker);
spinner = (Spinner) findViewById(R.id.background_spinner);
/* For title */
title.setOnEditorActionListener(new TextView.OnEditorActionListener() {
#Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEND) {
// I think here is the most important part.
addActivity_scrollview.smoothScrollTo(0, numberPicker.getBottom());
}
return false;
}
});
}
}
For addActivity_scrollview.smoothScrollTo(0, numberPicker.getBottom());,
I've tried many possible codes, such as
addActivity_scrollview.smoothScrollTo(0, spinner.getTop());
addActivity_scrollview.smoothScrollTo(0, 300); (300 is just a random number)
addActivity_scrollview.smoothScrollBy(0, 300);
but the scroll is always stuck (it moves a little but it's always the same position with above codes) and the screen barely shows the selected number of NumberPicker. How can I achieve the goal to set scroll so that the screen shows the entire NumberPicker?
just add this line to your edittext code in xml :android:imeOptions="actionSend" and then just try this into your activityaddActivity_scrollview.smoothScrollTo(0, 480);
I should've added android:imeOptions="actionSend" to <EditText> in order to properly listen on onEditorAction(). I thought it'd be okay with android:singLine="true" because that option enabled "next" action on keyboard.
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/title_editText"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:hint="#string/hint_title"
android:singleLine="true"
android:maxLength="20"
android:imeOptions="actionSend" />
I have a AlertDialog that is shown when there is an error and it prints 'Error, could not be added/whatever", I also have the result of the exception that I'd like to parse but not shown to all users, only to those that want to click on 'details' and read the exception.
AlertDialog.Builder dialogo1 = new AlertDialog.Builder(activity);
dialogo1.setTitle("Error");
dialogo1.setMessage("Could not update movie: " + result);
dialogo1.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogo1, int id) {
activity.finish();
}
});
dialogo1.show();
There is my code, pretty simple, right? I haven't been able to find this answer anyway and I'm starting to think it is just not possible
what you want is a custom alert dialog.
so for that you will have to us a layout and define your dialog.Then initialize your listeners etc like it was a normal view that you are defining
dialog_layout.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:src="#drawable/header_logo"
android:layout_width="match_parent"
android:layout_height="64dp"
android:scaleType="center"
android:background="#FFFFBB33"
android:contentDescription="#string/app_name" />
<TextView
android:id="#+id/error"
andorid:text="Error Message"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:id="#+id/moreDetailsButton"
android:text="Click for more details"
android:inputType="textPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:id="#+id/moreDetailsView"
android:text="Click for more details"
android:inputType="textPassword"
android:layout_width="match_parent"
android:visibility="gone";
android:layout_height="wrap_content"/>
<Button
android:id="#+id/dialogButtonOK"
android:layout_width="100px"
android:layout_height="wrap_content"
android:text=" Ok "
android:layout_marginTop="5dp"
android:layout_marginRight="5dp"
android:layout_below="#+id/moreDetailsButton"
/>
</RelativeLayout>
and in your class
final Dialog dialog = new Dialog(context);
dialog.setContentView(R.layout.dialog_layout);
TextView error=(TextView)dialog.findViewById(R.id.error);
Button errorButton=(Button)dialog.findViewById(R.id.moreDetailsButton);
Button okButton=(Button)dialog.findViewById(R.id.ok);
//Do whatever you want with the rest of the dialog
// initialize all the onclick listeners a usual
errorButton.setOnClickListener(new View.onClickListener(){
#Override
public void onClick(View v){
TextView errorDetails=(TextView)dialog.findViewById(R.id.moreDetailsView);
errorDetails.setText(detailedErrorMessage) //add the details to this text view;
errorDetails.setVisibility(View.VISIBLE);
}
});
dialog.show();
Sorry if there are any syntactically errors if the ctrl+c,ctrl+v of this doesnt work.My IDE decided to misbehave today.
Follow this for details on a custom alert dialog.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="#+id/error"
android:text="Error Message"
android:layout_width="match_parent"
android:layout_height="37dp"
android:layout_toEndOf="#+id/moreDetailsView"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true" />
<TextView
android:id="#+id/moreDetailsView"
android:text="No existen detalles para este tipo de error."
android:layout_width="match_parent"
android:visibility="gone"
android:layout_height="wrap_content" />
<Button
android:id="#+id/moreDetailsButton"
android:text="Click for more details"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toEndOf="#+id/moreDetailsView"
android:layout_below="#+id/error"
android:layout_alignParentStart="true" />
<Button
android:id="#+id/dialogButtonOK"
android:layout_width="139dp"
android:layout_height="wrap_content"
android:text="OK"
android:layout_centerVertical="true"
android:layout_toEndOf="#+id/moreDetailsView"
android:layout_gravity="center_horizontal" />
</LinearLayout>
</RelativeLayout>
This is my first post and I hope I won't make any mistakes writing it. I am in the process of making my own application, and I got stuck at this point.
I have a GridView with a custom layout, which has two views on top of each other (an ImageButton and an overlay, so to speak). I was trying to implement something that sounds like this: when I click on the Button, some views on the Activity would change:
//listener code goes here
title.setText("Title");
description.setText("Description);
preview.setAlpha(1.0f);
lock.setVisibility(View.GONE);
After a lot of failed attempts of trying to implement the OnItemClickListener(), I took the conclusion that I need to implement a OnClickListener() on the button in the BaseAdapter. However, I don't know how I can possibly do that.
I've tried a lot of things, like implementing a method on the Activity class to change them and then call it. I got a non-static error. I've also tried implementing an AsyncTask that checks for changes in a static variable in the Activity every 100ms. (That worked only once and then stopped) It works fine now. It was something like this:
public class UpdateChecker extends AsyncTask <Void, Void, Void>
{
#Override
protected Void doInBackground(Void... voids)
{
while(true)
{
if(selected)
{
Start();
selected = false;
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
The OnClickListener was like:
viewButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view)
{
CustomizeActivity.currId = TargetManager.getTarget(position).ID;
CustomizeActivity.selected = true;
CustomizeActivity.currpos = position;
}
});
(The values set are static)
XML:
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="100dp"
android:layout_above="#+id/setButton"
android:layout_centerHorizontal="true"
android:background="#ff191919"
android:id="#+id/relativeLayout">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/frameLayout"
android:layout_toEndOf="#+id/frameLayout"
android:layout_alignTop="#+id/frameLayout">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title"
android:id="#+id/titleView"
android:layout_toEndOf="#+id/preView"
android:textSize="30dp"
android:textColor="#ffeaeaea"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This is a sample long description. I am testing."
android:id="#+id/descriptionView"
android:layout_toEndOf="#+id/preView"
android:textColor="#ffcdcdcd"
android:textSize="20dp"
android:layout_below="#+id/titleView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="5dp" />
</RelativeLayout>
<FrameLayout
android:layout_width="100dp"
android:layout_height="100dp"
android:id="#+id/frameLayout"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:id="#+id/preView"
android:src="#drawable/target_hellokitty"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/imageView"
android:layout_alignParentStart="true"
android:layout_alignTop="#+id/preView"
android:layout_alignLeft="#+id/preView"
android:layout_alignRight="#+id/preView"
android:layout_alignBottom="#+id/preView"
android:src="#android:drawable/ic_lock_lock" />
</FrameLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/relativeLayout"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<TabHost
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/tabHost"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TabWidget
android:id="#android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"></TabWidget>
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="#+id/tab1"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<GridView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/gridView"
android:numColumns="auto_fit"
android:stretchMode="columnWidth"
android:columnWidth="100dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/tab2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"></LinearLayout>
<LinearLayout
android:id="#+id/tab3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"></LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
</RelativeLayout>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Set Button"
android:id="#+id/setButton"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="#ff00a4e1"
android:textColor="#ffffffff" />
Do you think implementing an ASyncTask as a listener with an infinite loop and a check is a good idea?