Skip to content

Commit

Permalink
init commit
Browse files Browse the repository at this point in the history
  • Loading branch information
fabOnReact committed Feb 17, 2022
1 parent d371cdd commit b0950f8
Show file tree
Hide file tree
Showing 15 changed files with 152 additions and 103 deletions.
6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/google-java-format.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions .idea/runConfigurations.xml

This file was deleted.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 40 additions & 30 deletions app/src/main/java/com/example/myapplication/MainActivity.java
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;
}

}
50 changes: 10 additions & 40 deletions app/src/main/res/layout/activity_main.xml
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>
8 changes: 8 additions & 0 deletions app/src/main/res/menu/activity_main.xml
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>
2 changes: 1 addition & 1 deletion app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
<color name="colorAccent">#D81B60</color>
<color name="red">#FF0000</color>
<color name="blue">#3333CC</color>
</resources>
</resources>
11 changes: 8 additions & 3 deletions app/src/main/res/values/strings.xml
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>
30 changes: 20 additions & 10 deletions app/src/main/res/values/styles.xml
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>
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {

}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.android.tools.build:gradle:7.0.4'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip

0 comments on commit b0950f8

Please sign in to comment.