-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,50 @@ | ||
package com.example.myapplication; | ||
|
||
import android.content.Context; | ||
import android.graphics.Color; | ||
import android.graphics.Rect; | ||
import android.util.Log; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import androidx.appcompat.app.AppCompatActivity; | ||
import android.widget.Button; | ||
import android.os.Bundle; | ||
import android.app.Activity; | ||
import android.view.Menu; | ||
import android.view.View; | ||
import android.widget.AdapterView; | ||
import android.widget.AdapterView.OnItemClickListener; | ||
import android.widget.ArrayAdapter; | ||
import android.widget.GridView; | ||
import android.widget.TextView; | ||
import android.widget.Toast; | ||
|
||
public class MainActivity extends AppCompatActivity { | ||
public class MainActivity extends Activity { | ||
GridView gridView; | ||
static final String[] numbers = new String[] { | ||
"1", "2", "3", "4", "5", | ||
"6", "7", "8", "9", "10",}; | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
ViewGroup linearLayout = findViewById(R.id.linear_layout); | ||
linearLayout.setBackgroundColor(Color.RED); | ||
getWindow().getDecorView().post(new Runnable() { | ||
@Override | ||
public void run() { | ||
// TODO your magic code to be run | ||
ViewGroup linearLayout = findViewById(R.id.linear_layout); | ||
int height = linearLayout.getHeight() ; | ||
int width = linearLayout.getWidth(); | ||
Log.w("TESTING::", "height: " + height); | ||
Rect scrollBounds = new Rect(); | ||
linearLayout.getHitRect(scrollBounds); | ||
Log.w("TESTING::", "scrollBound: " + scrollBounds); | ||
final int childCount = linearLayout.getChildCount(); | ||
for (int i = 0; i < childCount; i++) { | ||
final View child = linearLayout.getChildAt(i); | ||
boolean isVisible = child.getLocalVisibleRect(scrollBounds); | ||
Log.w("TESTING::", "child i: " + i + " isVisible: " + isVisible); | ||
} | ||
} | ||
|
||
gridView = (GridView) findViewById(R.id.gridView1); | ||
|
||
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, | ||
android.R.layout.simple_list_item_1, numbers); | ||
|
||
gridView.setAdapter(adapter); | ||
|
||
gridView.setOnItemClickListener(new OnItemClickListener() { | ||
|
||
@Override | ||
public void onItemClick(AdapterView<?> parent, View view, int position,long id) { | ||
Toast.makeText(getApplicationContext(),((TextView) view).getText(), Toast.LENGTH_LONG).show(); | ||
|
||
} | ||
|
||
|
||
}); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean onCreateOptionsMenu(Menu menu) { | ||
// Inflate the menu; this adds items to the action bar if it is present. | ||
getMenuInflater().inflate(R.menu.activity_main, menu); | ||
return true; | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!DOCTYPE RelativeLayout> | ||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:fillViewport="true"> | ||
<TableLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:id="@+id/linear_layout" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
<TextView | ||
android:id="@+id/text_view_id" | ||
android:layout_width="157dp" | ||
android:layout_height="500dp" | ||
android:layout_marginBottom="10dp" | ||
android:background="@color/blue" | ||
android:text="Hello this is my first" | ||
android:textColor="@color/red" | ||
android:textSize="100dp" /> | ||
<TextView | ||
android:id="@+id/text_view_id" | ||
android:layout_width="157dp" | ||
android:layout_height="500dp" | ||
android:background="@color/blue" | ||
android:textColor="@color/red" | ||
android:layout_marginBottom="10dp" | ||
android:textSize="100dp" | ||
android:text="Hello this is my second" /> | ||
<TextView | ||
android:id="@+id/text_view_id" | ||
android:layout_width="157dp" | ||
android:layout_height="500dp" | ||
android:background="@color/blue" | ||
android:textColor="@color/red" | ||
android:layout_marginBottom="10dp" | ||
android:textSize="100dp" | ||
android:text="hello" /> | ||
</TableLayout> | ||
</ScrollView> | ||
<GridView xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:id="@+id/gridView1" | ||
android:numColumns="3" | ||
android:gravity="center" | ||
android:columnWidth="50dp" | ||
android:stretchMode="columnWidth" | ||
android:layout_width="fill_parent" | ||
android:layout_height="fill_parent" > | ||
|
||
</GridView> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<menu xmlns:android="http://schemas.android.com/apk/res/android" > | ||
|
||
<item | ||
android:id="@+id/menu_settings" | ||
android:orderInCategory="100" | ||
android:title="@string/menu_settings"/> | ||
|
||
</menu> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
<resources> | ||
<string name="app_name">My Application</string> | ||
</resources> | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
|
||
<string name="app_name">gridview</string> | ||
<string name="hello_world">Hello world!</string> | ||
<string name="menu_settings">Settings</string> | ||
|
||
</resources> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,20 @@ | ||
<resources> | ||
|
||
<!-- Base application theme. --> | ||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> | ||
<!-- Customize your theme here. --> | ||
<item name="colorPrimary">@color/colorPrimary</item> | ||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> | ||
<item name="colorAccent">@color/colorAccent</item> | ||
</style> | ||
</resources> | ||
<resources> | ||
|
||
<!-- | ||
Base application theme, dependent on API level. This theme is replaced | ||
by AppBaseTheme from res/values-vXX/styles.xml on newer devices. | ||
--> | ||
<style name="AppBaseTheme" parent="android:Theme.Light"> | ||
<!-- | ||
Theme customizations available in newer API levels can go in | ||
res/values-vXX/styles.xml, while customizations related to | ||
backward-compatibility can go here. | ||
--> | ||
</style> | ||
|
||
<!-- Application theme. --> | ||
<style name="AppTheme" parent="AppBaseTheme"> | ||
<!-- All customizations that are NOT specific to a particular API-level can go here. --> | ||
</style> | ||
|
||
</resources> |